# US 12,602,331 B2 · Memory page tables sharing method and apparatus

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 12,602,331 B2
- Document ID: US12602331B2
- Status: Granted
- Kind: B2
- Application number: 18/940,993
- Filed: 2024-11-08
- Published: 2025-02-27
- Granted: 2026-04-14
- Earliest claimed: 2022-05-10
- Assignees: Huawei Technologies Co., Ltd.
- Applicants: Huawei Technologies Co., Ltd.
- Inventors: Rujie Chen
- Web page: https://patentgrep.com/patent/US12602331B2

## CPC

- G06F 12/1009: using page tables, e.g. page table structures
- G06F 12/084: with a shared cache
- G06F 12/0882: Page mode
- G06F 12/1072: Decentralised address translation, e.g. in distributed shared memory systems
- G06F 12/1081: for peripheral access to main memory, e.g. direct memory access [DMA]
- G06F 12/109: for multiple virtual address spaces, e.g. segmentation (G06F12/1036 takes precedence)
- G06F 2212/1024: Latency reduction
- G06F 2212/657: Virtual address space management
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Embodiments of this application disclose a memory sharing method and an apparatus. The method in embodiments of this application includes: A host side establishes a first memory page table via a shared virtual address management unit. The first memory page table includes mapping from a virtual address on the host side to a physical address on the host side. A first device side establishes a second memory page table via a shared virtual address agent unit. The second memory page table includes mapping from a virtual address on the first device side to a physical address on the first device side. An agent system memory management unit SMMU on the first device side updates the second memory page table based on the first memory page table, or the host side updates the first memory page table based on the second memory page table.

## Claims

### Claim 1

A memory sharing method, used in a heterogeneous system, wherein the heterogeneous system comprises a host side and a first device side, and the method comprises:
establishing, by the host side, a first memory page table, wherein the first memory page table comprises mapping from a virtual address on the host side to a physical address on the host side;
establishing, by the first device side, a second memory page table, wherein the second memory page table comprises mapping from a virtual address on the first device side to a physical address on the first device side, and the physical address on the host side and the physical address on the first device side are physical addresses obtained through unified addressing; and
updating, by an agent system memory management unit (SMMU) on the first device side, the second memory page table based on the first memory page table, and updating, by the host side, the first memory page table based on the second memory page table.

### Claim 2 (depends on 1)

The method according to claim 1, wherein the updating, by SMMU on the first device side, the second memory page table based on the first memory page table comprises:
querying, by the agent SMMU on the first device side, the first memory page table based on a first virtual address, to obtain a first physical address, wherein the first virtual address is a virtual address to be accessed by the first device side, and the first physical address is a physical address on the host side; and
adding, by the first device side, mapping from the first virtual address to the first physical address to the second memory page table.

### Claim 3 (depends on 2)

The method according to claim 2, wherein after the adding, by the first device side, mapping from the first virtual address to the first physical address to the second memory page table, the method further comprises:
querying, by the first device side, the second memory page table based on the first virtual address, to obtain the first physical address; and
accessing, by the first device side, a memory on the host side based on the first physical address.

### Claim 4 (depends on 1)

The method according to claim 1, wherein the updating, by the host side, the first memory page table based on the second memory page table comprises:
querying, by the first device side, the second memory page table based on a second virtual address, to obtain a second physical address, wherein the second physical address is a physical address on the first device side; and
adding, by the host side, mapping from the second virtual address to the second physical address to the first memory page table.

### Claim 5 (depends on 4)

The method according to claim 4, wherein before the querying, by the first device side, the second memory page table based on the second virtual address, the method further comprises:
sending, by the host side, the second virtual address to the first device side, wherein the second virtual address comprises a virtual address allocated on the host side;
allocating, by the first device side, a physical memory to the second virtual address, to obtain the second physical address; and
adding, by the first device side, the mapping from the second virtual address to the second physical address to the second memory page table.

### Claim 6 (depends on 4)

The method according to claim 4, wherein after the adding, by the host side, mapping from the second virtual address to the second physical address to the first memory page table, the method further comprises:
querying, by the host side, the first memory page table based on the second virtual address, to obtain the second physical address; and
accessing, by the host side, a memory on the first device side based on the second physical address.

### Claim 7 (depends on 4)

The method according to claim 4, wherein the heterogeneous system further comprises a second device side, and after the adding, by the host side, mapping from the second virtual address to the second physical address to the first memory page table, the method further comprises:
updating, by an agent SMMU on the second device side, a third memory page table based on the first memory page table, wherein the first memory page table comprises the mapping from the second virtual address to the second physical address;
querying, by the second device side, the third memory page table based on the second virtual address, to obtain the second physical address; and
accessing, by the second device side, a memory on the first device side based on the second physical address.

### Claim 8

A memory sharing method, used in a heterogeneous system, wherein the heterogeneous system comprises a host side and a first device side, and the method comprises:
performing, by the host side, unified addressing on memory space of the heterogeneous system, to obtain a memory page table, wherein the memory page table comprises mapping from a virtual address to a physical address in the heterogeneous system;
the first device side accesses a first virtual address in the heterogeneous system by querying, by a system memory management unit (SMMU) on the first device side, the memory page table based on the first virtual address, to obtain a first physical address, wherein the first physical address comprises a physical address on the host side; and
accessing, by the first device side, a memory on the host side based on the first physical address,
wherein the querying by SMMU on the first device side, the memory page table based on the first virtual address comprises:
sending, by the SMMU on the first device side, the first virtual address to an agent SMMU on the first device side;
querying, by the agent SMMU on the first device side, the memory page table, to obtain the first physical address; and
sending, by the agent SMMU on the first device side, the physical first physical address to the SMMU of a first device via a dispatch module.

### Claim 9 (depends on 8)

The method according to claim 8, wherein after the performing, by the host side, unified addressing on memory space of the heterogeneous system, the method further comprises:
storing, by the host side, the memory page table on the first device side.

### Claim 10

An electronic device, comprising a processor, wherein the processor is coupled to a storage, the processor is configured to store instructions, and when the instructions are executed by the processor, the electronic device is enabled to:
establish, by a host side, a first memory page table, wherein the first memory page table comprises mapping from a virtual address on the host side to a physical address on the host side;
establish, by a first device side, a second memory page table, wherein the second memory page table comprises mapping from a virtual address on the first device side to a physical address on the first device side, and the physical address on the host side and the physical address on the first device side are physical addresses obtained through unified addressing; and
update, by an agent system memory management unit (SMMU) on the first device side, the second memory page table based on the first memory page table, and update, by the host side, the first memory page table based on the second memory page table.

### Claim 11 (depends on 10)

The electronic device according to claim 10, wherein, the updating, by the agent SMMU on the first device side, the second memory page table based on the first memory page table comprises:
querying, by the agent SMMU on the first device side, the first memory page table based on a first virtual address, to obtain a first physical address, wherein the first virtual address is a virtual address to be accessed by the first device side, and the first physical address is a physical address on the host side; and
adding, by the first device side, mapping from the first virtual address to the first physical address to the second memory page table.

### Claim 12 (depends on 11)

The electronic device according to claim 11, wherein after the adding, by the first device side, mapping from the first virtual address to the first physical address to the second memory page table, the method further comprises:
querying, by the first device side, the second memory page table based on the first virtual address, to obtain the first physical address; and
accessing, by the first device side, a memory on the host side based on the first physical address.

### Claim 13 (depends on 10)

The electronic device according to claim 10, wherein the updating, by the host side, the first memory page table based on the second memory page table comprises:
querying, by the first device side, the second memory page table based on a second virtual address, to obtain a second physical address, wherein the second physical address is a physical address on the first device side; and
adding, by the host side, mapping from the second virtual address to the second physical address to the first memory page table.

### Claim 14 (depends on 13)

The electronic device according to claim 13, wherein before the querying, by the first device side, the second memory page table based on the second virtual address, the method further comprises:
sending, by the host side, the second virtual address to the first device side, wherein the second virtual address comprises a virtual address allocated on the host side;
allocating, by the first device side, a physical memory to the second virtual address, to obtain the second physical address; and
adding, by the first device side, the mapping from the second virtual address to the second physical address to the second memory page table.

### Claim 15 (depends on 13)

The electronic device according to claim 13, wherein after the adding, by the host side, mapping from the second virtual address to the second physical address to the first memory page table, the method further comprises:
querying, by the host side, the first memory page table based on the second virtual address, to obtain the second physical address; and
accessing, by the host side, a memory on the first device side based on the second physical address.

### Claim 16 (depends on 13)

The electronic device according to claim 13, wherein the heterogeneous system further comprises a second device side, and after the adding, by the host side, mapping from the second virtual address to the second physical address to the first memory page table, the method further comprises:
updating, by an agent SMMU on the second device side, a third memory page table based on the first memory page table, wherein the first memory page table comprises the mapping from the second virtual address to the second physical address;
querying, by the second device side, the third memory page table based on the second virtual address, to obtain the second physical address; and
accessing, by the second device side, a memory on the first device side based on the second physical address.
