cloud-hypervisor/docs
Anatol Belski e1cc702327 memory_manager: Fix address range calculation in MemorySlot
The MCRS method returns a 64-bit memory range descriptor. The
calculation is supposed to be done as follows:

max = min + len - 1

However, every operand is represented not as a QWORD but as combination
of two DWORDs for high and low part. Till now, the calculation was done
this way, please see also inline comments:

max.lo = min.lo + len.lo //this may overflow, need to carry over to high
max.hi = min.hi + len.hi
max.hi = max.hi - 1 // subtraction needs to happen on the low part

This calculation has been corrected the following way:

max.lo = min.lo + len.lo
max.hi = min.hi + len.hi + (max.lo < min.lo) // check for overflow
max.lo = max.lo - 1 // subtract from low part

The relevant part from the generated ASL for the MCRS method:
```
Method (MCRS, 1, Serialized)
{
    Acquire (MLCK, 0xFFFF)
    \_SB.MHPC.MSEL = Arg0
    Name (MR64, ResourceTemplate ()
    {
	QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite,
	    0x0000000000000000, // Granularity
	    0x0000000000000000, // Range Minimum
	    0xFFFFFFFFFFFFFFFE, // Range Maximum
	    0x0000000000000000, // Translation Offset
	    0xFFFFFFFFFFFFFFFF, // Length
	    ,, _Y00, AddressRangeMemory, TypeStatic)
    })
    CreateQWordField (MR64, \_SB.MHPC.MCRS._Y00._MIN, MINL)  // _MIN: Minimum Base Address
    CreateDWordField (MR64, 0x12, MINH)
    CreateQWordField (MR64, \_SB.MHPC.MCRS._Y00._MAX, MAXL)  // _MAX: Maximum Base Address
    CreateDWordField (MR64, 0x1A, MAXH)
    CreateQWordField (MR64, \_SB.MHPC.MCRS._Y00._LEN, LENL)  // _LEN: Length
    CreateDWordField (MR64, 0x2A, LENH)
    MINL = \_SB.MHPC.MHBL
    MINH = \_SB.MHPC.MHBH
    LENL = \_SB.MHPC.MHLL
    LENH = \_SB.MHPC.MHLH
    MAXL = (MINL + LENL) /* \_SB_.MHPC.MCRS.LENL */
    MAXH = (MINH + LENH) /* \_SB_.MHPC.MCRS.LENH */
    If ((MAXL < MINL))
    {
	MAXH += One /* \_SB_.MHPC.MCRS.MAXH */
    }

    MAXL -= One
    Release (MLCK)
    Return (MR64) /* \_SB_.MHPC.MCRS.MR64 */
}
```

Fixes #1800.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2021-04-12 16:20:19 +02:00
..
api.md ch: Fix various misspelled words 2020-09-23 08:59:31 +01:00
arm64.md docs: Remove all virtio-mmio references 2020-10-19 14:58:48 +01:00
custom-image.md doc: Update documentation to note removal of pollinate package 2021-01-11 16:38:07 +00:00
debug-port.md docs: Replace every mention of ClearLinux with Ubuntu 2020-07-03 14:37:09 +02:00
device_model.md docs: Update the device model documentation 2021-03-16 20:27:15 +08:00
fs.md docs/virtio-fs: Update --memory option parameters 2020-08-19 10:43:04 +02:00
fuzzing.md fuzz: Add fuzzing infrastructure and QCOW fuzzer 2020-07-17 08:49:35 +02:00
hotplug.md docs: Update hotplug documentation with ch-remote 2021-03-23 14:55:49 -07:00
intel_sgx.md docs: Update documentation to not use bzImage 2021-04-06 13:30:59 +02:00
io_throttling.md virtio-devices: Add rate limiter for the RX queue of virtio-net 2021-03-30 19:47:43 +02:00
iommu.md docs: Update documentation to not use bzImage 2021-04-06 13:30:59 +02:00
logging.md docs: Add documentation about the log levels and when to use them 2020-10-06 16:52:29 +01:00
macvtap-bridge.md docs: Add instructions for using MACVTAP for bridging 2020-12-17 22:51:30 +01:00
memory.md docs: Update documentation for hugepage_size option 2021-02-05 09:24:02 +00:00
networking.md ch: Fix various misspelled words 2020-09-23 08:59:31 +01:00
profiling.md docs: Add instructions for using perf 2020-11-27 19:19:14 +01:00
seccomp.md docs: Add seccomp documentation 2021-03-23 18:41:30 +01:00
snapshot_restore.md docs: Update documentation to not use bzImage 2021-04-06 13:30:59 +02:00
uefi.md doc: Add notes to compile OVMF with legacy support 2020-11-09 17:41:03 +01:00
vfio.md docs: vfio: Remove documentation regarding VFIO limitations 2021-02-10 17:34:56 +00:00
vhost-user-blk-testing.md docs: use shared memory with vhost-user 2020-08-11 19:37:31 +02:00
vhost-user-net-testing.md docs: use shared memory with vhost-user 2020-08-11 19:37:31 +02:00
virtiofs-root.md docs: Add virtiofs root howto 2021-03-16 00:10:49 +01:00
windows.md memory_manager: Fix address range calculation in MemorySlot 2021-04-12 16:20:19 +02:00