# US 2017/0286149 A1 · Method for Managing Memory of Virtual Machine, Physical Host, PCIE Device and Configuration Method Thereof, and Migration Management Device

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

- Number: US 2017/0286149 A1
- Document ID: US20170286149A1
- Status: Published application
- Kind: A1
- Application number: 15/630,467
- Filed: 2017-06-22
- Published: 2017-10-05
- Earliest claimed: 2015-01-27
- Assignees: Huawei Technologies Co., Ltd.
- Applicants: Huawei Technologies Co., Ltd.
- Inventors: Shengwen Lu
- Web page: https://patentgrep.com/patent/US20170286149A1

## CPC

- G06F 9/45558: {Hypervisor-specific management and integration aspects}
- G06F 12/0292: {using tables or multilevel address translation means (G06F12/023 takes precedence; address translation in virtual memory systems G06F12/10)}
- G06F 12/1009: using page tables, e.g. page table structures
- G06F 12/1027: using associative or pseudo-associative address translation means, e.g. translation look-aside buffer [TLB]
- G06F 13/105: {where the program performs an input/output emulation function}
- G06F 13/4282: {on a serial bus, e.g. I2C bus, SPI bus (on daisy chain buses G06F13/4247)}
- G06F 2009/4557: {Distribution of virtual machine instances; Migration and load balancing}
- G06F 2009/45579: {I/O management, e.g. providing access to device drivers or storage}
- G06F 2009/45583: {Memory management, e.g. access or allocation}
- G06F 2212/151: Emulated environment, e.g. virtual machine
- G06F 2212/6042: Allocation of cache space to multiple users or processors
- G06F 2212/65: Details of virtual memory and virtual address translation
- G06F 2212/68: Details of translation look-aside buffer [TLB]
- G06F 2213/0026: PCI express
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method for managing a memory of a virtual machine, a physical host, a PCIE device and a configuration method thereof are provided. The method executed by a virtual machine includes: allocating a memory to a service carried on a PCIE device, where the memory includes multiple memory blocks, the multiple memory blocks is used to save working information of the service; generating a base address table BAT and a chip logic address table CLAT, where the BAT includes a CLAT entry base address corresponding to the service, and the CLAT includes a first address of each memory block; and sending an address of the BAT and a function number corresponding to the virtual machine to the PCIE device. Therefore, the PCIE device can obtain, according to the address of the BAT and the function number, working information of a service from the virtual machine.

## Claims

### Claim 1

A method, comprising:
allocating, by a virtual machine, a memory to one or more services carried on a Peripheral Component Interconnect Express (PCIE) device, wherein the memory allocated to each service comprises a plurality of memory blocks, each of the plurality of memory blocks is used to save working information of a corresponding service, and each memory block is a section of memory space in which guest physical addresses are consecutive, wherein the virtual machine runs on a physical host, the physical host is connected to a PCIE device, the PCIE device is a hardware device that supports the single-root I/O virtualization (SR-IOV) standard, and the PCIE device has a physical function (PF) and a virtual function (VF), wherein a unique function number is configured for each PF and each VF separately;
generating, by the virtual machine, a base address table (BAT) and a chip logic address table (CLAT) according to the memory allocated to each service, wherein the BAT comprises a CLAT entry base address corresponding to each service, and the CLAT comprises a first address of each memory block; and
sending, by the virtual machine, an address of the BAT and a function number corresponding to the virtual machine to the PCIE device.

### Claim 2 (depends on 1)

The method according to claim 1, wherein the one or more services comprises a to-be-processed service, and the method further comprises:
receiving a request message to obtain working information of the to-be-processed service that is sent by the PCIE device, wherein the request message comprises the address of the BAT, a service type of the to-be-processed service, and a service number of the to-be-processed service; and
sending, to the PCIE device according to the request message, working information in a memory block corresponding to the to-be-processed service.

### Claim 3 (depends on 2)

The method according to claim 2, wherein sending the working information in the memory block corresponding to the to-be-processed service comprises:
obtaining the BAT corresponding to the address of the BAT;
determining, according to the service type of the to-be-processed service and the BAT, a CLAT entry base address corresponding to the service type;
determining an entry offset according to the service number of the to-be-processed service;
obtaining, according to the CLAT entry base address and the entry offset, a CLAT entry corresponding to the to-be-processed service; and
sending, to the PCIE device, the working information in a memory block corresponding to the CLAT entry that corresponds to the to-be-processed service.

### Claim 4 (depends on 3)

The method according to claim 3, wherein the CLAT is a single-level CLAT or a multi-level CLAT;
wherein the multi-level CLAT comprises N levels of CLAT, wherein N≧2, and N is an integer;
wherein each level of CLAT comprises multiple entries;
wherein each entry in the nth level of CLAT indicates an address of the (n+1)th level of CLAT, wherein 2≦n<n+1<N, and n is an integer; and
wherein each entry in the Nth level of CLAT indicates a first address of one of the memory blocks.

### Claim 5 (depends on 4)

The method according to claim 4, wherein sizes of the plurality of memory blocks allocated to the to-be-processed service are the same; and
wherein determining the entry offset according to the service number of the to-be-processed service comprises:
when the CLAT is a single-level CLAT, multiplying the service number of the to-be-processed service by a size of a memory occupied by the working information of the to-be-processed service, and dividing a result of the multiplication by the size of the memory block allocated to the to-be-processed service, to obtain a quotient and a remainder for the single-level CLAT, wherein when the remainder for the single-level CLAT is greater than 0, the entry offset is equal to the quotient for the single-level CLAT, or when the remainder for the single-level CLAT is equal to 0, the entry offset is equal to the quotient for the single-level CLAT minus 1; or when the CLAT is a multi-level CLAT, wherein the entry offset comprises an entry offset of each level of CLAT, calculating an entry offset of the xth level of CLAT in the following manner:
{
Service


number
×
A
C
N
-
X
×
B
=
Quotient


and


remainder


for

the


x
th


level


of


CLAT
,
x
=
1
Remainder


for


the
(
x
-
1
)
th


level


of


CLAT
×
A

C
N
-
X
×
B
=
Quotient


and


remainder


for

the


x
th



level


of


CLAT
,
N
≥
x
≥
2
wherein when a remainder for the xth level of CLAT is greater than 0, the entry offset of the xth level of CLAT is equal to a quotient for the xth level of CLAT; or when a remainder for the xth level of CLAT is equal to 0, the entry offset of the xth level of CLAT is equal to a quotient for the xth level of CLAT minus 1, wherein A is a size of a memory occupied by the working information of the to-be-processed service, B is the size of the memory block allocated to the to-be-processed service, and C is a quantity of entries in the Nth level of CLAT.

### Claim 6

A method for configuring a Peripheral Component Interconnect Express (PCIE) device, comprising:
receiving, by a PCIE device, an address of a base address table (BAT) on each virtual machine and a function number corresponding to each virtual machine, wherein the PCIE device is connected to a physical host, one or more virtual machines run on the physical host, the PCIE device is a hardware device that supports the single-root I/O virtualization (SR-IOV) standard, and the PCIE device has a physical function (PF) and a virtual function (VF), wherein a unique function number is configured for each PF and each VF separately, wherein each virtual machine comprises the BAT, wherein the BAT is generated by a virtual machine, to which the BAT belongs, according to a memory allocated to one or more services carried on the PCIE device, the memory allocated to each service comprises a plurality of memory blocks, each of the plurality of memory blocks is used to save working information of a corresponding service, each memory block is a section of memory space in which guest physical addresses are consecutive, the BAT comprises a chip logic address table (CLAT) entry base address corresponding to each service, and a CLAT comprises a first address of each memory block; and
saving a correspondence between the address of the BAT and the function number into a virtual machine configuration table (VCT).

### Claim 7 (depends on 6)

The method according to claim 6, wherein the one or more services comprises a to-be-processed service, and the method further comprises:
determining, according to service information of the to-be-processed service and the VCT, an address of a BAT corresponding to the to-be-processed service; and
obtaining, from a memory corresponding to the to-be-processed service, working information of the to-be-processed service according to the address of the BAT corresponding to the to-be-processed service, a service type of the to-be-processed service, and a service number of the to-be-processed service.

### Claim 8 (depends on 7)

The method according to claim 7, wherein determining the address of the BAT corresponding to the to-be-processed service comprises:
receiving the service information, sent by a host side or a network side, of the to-be-processed service;
determining a function number corresponding to the to-be-processed service, according to a feature in the service information, sent by the host side, of the to-be-processed service or according to a PCIE interface used when the service information, transmitted by the host side, of the to-be-processed service is received, wherein the feature indicates the function number corresponding to the to-be-processed service; and
determining, according to the VCT and the determined function number corresponding to the to-be-processed service, the address of the BAT corresponding to the function number that is corresponding to the to-be-processed service.

### Claim 9 (depends on 8)

The method according to claim 8, wherein obtaining the working information of the to-be-processed service according to the address of the BAT corresponding to the to-be-processed service, the service type of the to-be-processed service, and the service number of the to-be-processed service comprises:
sending a request message to a virtual machine corresponding to the determined function number that corresponds to the to-be-processed service, wherein the request message comprises the address of the BAT corresponding to the function number that corresponds to the to-be-processed service, the service type of the to-be-processed service, and the service number of the to-be-processed service; and
receiving working information, of the to-be-processed service, sent by the virtual machine corresponding to the function number that corresponda to the to-be-processed service, wherein the working information of the to-be-processed service is obtained from a memory block corresponding to the request message by the virtual machine corresponding to the function number that is corresponding to the to-be-processed service.

### Claim 10 (depends on 7)

The method according to claim 7, wherein obtaining the working information of the to-be-processed service according to the address of the BAT corresponding to the to-be-processed service, the service type of the to-be-processed service, and the service number of the to-be-processed service comprises:
reading, according to the address of the BAT corresponding to the to-be-processed service, the BAT corresponding to the to-be-processed service;
determining, according to the service type of the to-be-processed service, a CLAT entry base address corresponding to the service type of the to-be-processed service from the BAT corresponding to the to-be-processed service;
determining an entry offset according to the service number of the to-be-processed service;
reading a CLAT entry corresponding to the entry offset and the CLAT entry base address that is corresponding to the service type of the to-be-processed service; and
reading working information in a memory block corresponding to the CLAT entry.

### Claim 11 (depends on 10)

The method according to claim 10, wherein the CLAT is a single-level CLAT or a multi-level CLAT;
wherein the multi-level CLAT comprises N levels of CLAT, wherein N≧2, and N is an integer;
wherein each level of CLAT comprises multiple entries;
wherein each entry in the nth level of CLAT indicates an address of the (n+1)th level of CLAT, wherein 2≦n<n+1<N, and n is an integer; and
wherein each entry in the Nth level of CLAT indicates a first address of one of the memory blocks.

### Claim 12

A physical host, configured to:
allocate a memory to one or more services carried on a Peripheral Component Interconnect Express (PCIE) device, wherein the memory allocated to each service comprises a plurality of memory blocks, each of the plurality of memory blocks is used to save working information of a corresponding service, and each memory block is a section of memory space in which guest physical addresses are consecutive, wherein a virtual machine runs on the physical host, the physical host is connected to the PCIE device, the PCIE device is a hardware device that supports the single-root I/O virtualization (SR-IOV) standard, and the PCIE device has at least one physical function (PF) and at least one virtual function (VF), wherein a unique function number is configured for each PF and each VF separately;
generate a base address table (BAT) and a chip logic address table (CLAT) according to the memory allocated to each service, wherein the BAT comprises a CLAT entry base address corresponding to each service, and the CLAT comprises a first address of each memory block; and
send an address of the BAT and a function number corresponding to the virtual machine to the PCIE device.

### Claim 13 (depends on 12)

The physical host according to claim 12, wherein the one or more services comprises a to-be-processed service, and the virtual machine is further configured to:
receive a request message that is used to obtain working information of the to-be-processed service and that is sent by the PCIE device, wherein the request message comprises the address of the BAT, a service type of the to-be-processed service, and a service number of the to-be-processed service; and
send, to the PCIE device according to the request message, working information in a memory block corresponding to the to-be-processed service.

### Claim 14 (depends on 13)

The physical host according to claim 13, wherein the virtual machine configured to:
obtain the BAT corresponding to the address of the BAT;
determine, according to the service type of the to-be-processed service and the BAT, a CLAT entry base address corresponding to the service type;
determine an entry offset according to the service number of the to-be-processed service;
obtain, according to the CLAT entry base address and the entry offset, a CLAT entry corresponding to the to-be-processed service; and
send, to the PCIE device, working information in a memory block corresponding to the CLAT entry that corresponds to the to-be-processed service.

### Claim 15 (depends on 14)

The physical host according to claim 14, wherein the CLAT is a single-level CLAT or a multi-level CLAT;
wherein the multi-level CLAT comprises N levels of CLAT, wherein N≧2, and N is an integer;
wherein each level of CLAT comprises multiple entries;
wherein each entry in the nth level of CLAT indicates an address of the (n+1)th level of CLAT, wherein 2≦n<n+1<N, and n is an integer; and
wherein each entry in the Nth level of CLAT indicates a first address of one of the memory blocks.

### Claim 16 (depends on 15)

The physical host according to claim 15, wherein sizes of the plurality of memory blocks allocated to the to-be-processed service are the same; and
wherein the virtual machine is configured to:
when the CLAT is a single-level CLAT, multiply the service number of the to-be-processed service by a size of a memory occupied by the working information of the to-be-processed service, and divide a result of the multiplication by the size of the memory block allocated to the to-be-processed service, to obtain a quotient and a remainder for the single-level CLAT, wherein when the remainder for the single-level CLAT is greater than 0, the entry offset is equal to the quotient for the single-level CLAT, or when the remainder for the single-level CLAT is equal to 0, the entry offset is equal to the quotient for the single-level CLAT minus 1; or
when the CLAT is a multi-level CLAT, wherein the entry offset comprises an entry offset of each level of CLAT, calculate an entry offset of the xth level of CLAT in the following manner:
{
Service


number
×
A
C
N
-
X
×
B
=
Quotient


and


remainder


for

the


x
th


level


of


CLAT
,
x
=
1
Remainder


for


the
(
x
-
1
)
th


level


of


CLAT
×
A

C
N
-
X
×
B
=
Quotient


and


remainder


for

the


x
th



level


of


CLAT
,
N
≥
x
≥
2
wherein when a remainder for the xth level of CLAT is greater than 0, the entry offset of the xth level of CLAT is equal to a quotient for the xth level of CLAT; or when a remainder for the xth level of CLAT is equal to 0, the entry offset of the xth level of CLAT is equal to a quotient for the xth level of CLAT minus 1, wherein A is a size of a memory occupied by the working information of the to-be-processed service, B is the size of the memory block allocated to the to-be-processed service, and C is a quantity of entries in the Nth level of CLAT.

### Claim 17

A Peripheral Component Interconnect Express (PCIE) device, configured to:
receive an address of a base address table (BAT) on each virtual machine and a function number corresponding to each virtual machine, wherein the PCIE device is connected to a physical host, one or more virtual machines run on the physical host, the PCIE device is a hardware device that satisfies the single-root I/O virtualization (SR-IOV) standard, and the PCIE device has a physical function (PF) and a virtual function (VF), wherein a unique function number is configured for each PF and each VF separately, wherein each virtual machine comprises a BAT, wherein the BAT is generated by a virtual machine, to which the BAT belongs, according to a memory allocated to one or more services carried on the PCIE device, wherein the memory allocated to each service comprises a plurality of memory blocks, each of the plurality of memory blocks is used to save working information of a corresponding service, each memory block is a section of memory space in which guest physical addresses are consecutive, and wherein the BAT comprises a chip logic address table (CLAT) entry base address corresponding to each service, and a CLAT comprises a first address of each memory block; and
save a correspondence between the address of the BAT and the function number into a virtual machine configuration table (VCT).

### Claim 18 (depends on 17)

The PCIE device according to claim 17, wherein the one or more services comprises a to-be-processed service, and the PCIE device further configured to:
determine, according to service information of the to-be-processed service and the VCT, an address of a BAT corresponding to the to-be-processed service; and
obtain, from a memory corresponding to the to-be-processed service, working information of the to-be-processed service according to the address of the BAT corresponding to the to-be-processed service, a service type of the to-be-processed service, and a service number of the to-be-processed service.

### Claim 19 (depends on 18)

The PCIE device according to claim 18, wherein the PCIE device is further configured to receive the service information, sent by a host side or a network side, of the to-be-processed service; and
wherein the PCIE device is configured to:
determine a function number corresponding to the to-be-processed service, according to a feature in the service information, sent by the host side, of the to-be-processed service or according to a PCIE interface used when the service information, transmitted by the host side, of the to-be-processed service is received, wherein the feature is used to indicate the function number corresponding to the to-be-processed service; and
determine, according to the VCT and the determined function number corresponding to the to-be-processed service, the address of the BAT corresponding to the function number that is corresponding to the to-be-processed service.

### Claim 20 (depends on 19)

The PCIE device according to claim 19, wherein the PCIE device is configured to:
send a request message to a virtual machine corresponding to the determined function number that corresponds to the to-be-processed service, wherein the request message comprises the address of the BAT corresponding to the function number that corresponds to the to-be-processed service, the service type of the to-be-processed service, and the service number of the to-be-processed service; and
receive working information, of the to-be-processed service, sent by the virtual machine corresponding to the function number that corresponds to the to-be-processed service, wherein the working information of the to-be-processed service is obtained from a memory block corresponding to the request message by the virtual machine corresponding to the function number that is corresponding to the to-be-processed service.
