Re: [Qemu-devel] [PATCH] pc: ACPI BIOS: use highest NUMA node for hotplug mem hole SRAT entry

2017-05-25 Thread Ladi Prosek
On Wed, May 24, 2017 at 11:38 AM, Igor Mammedov  wrote:
> On Wed, 24 May 2017 11:16:14 +0200
> Ladi Prosek  wrote:
>
>> On Wed, May 24, 2017 at 11:07 AM, Laszlo Ersek  wrote:
>> > On 05/24/17 10:09, Ladi Prosek wrote:
>> >> For reasons unknown, Windows won't online all memory, both at command
>> >> line and hot-plugged later, unless the hotplug mem hole SRAT entry
>> >> specifies a node greater or equal to the ones where memory is added.
>> >
>> > s/greater or equal to/greater *than* or equal to/
>> >
>> > Thanks,
>> > Laszlo
>> > (always finding the important issues! ;) )
>>
>> Haha, thanks! Igor, please let me know if you'd like me to send a
>> corrected version.
> if you are going to respin see for nit below
>
> also could you check that 'make V=1 check' is happy,
> since patch changes SRAT table, bios tables test may fail
> if that happen then please add to commit message
> you can verify that updating reference blobs fixes make check with
> tests/acpi-test-data/rebuild-expected-aml.sh

Yes, a couple of tests print a warning (but still pass) with this
change. Sending v2 now and curious what comes back from patchew this
time :)

> ---
> note to maintainer:
> tests/acpi-test-data need to be updated due to change in SRAT table
>
>>
>> >>
>> >> Using the highest node on the machine makes recent versions of Windows
>> >> happy.
>> >>
>> >> With this example command line:
>> >>   ... \
>> >>   -m 1024,slots=4,maxmem=32G \
>> >>   -numa node,nodeid=0 \
>> >>   -numa node,nodeid=1 \
>> >>   -numa node,nodeid=2 \
>> >>   -numa node,nodeid=3 \
>> >>   -object memory-backend-ram,size=1G,id=mem-mem1 \
>> >>   -device pc-dimm,id=dimm-mem1,memdev=mem-mem1,node=1
>> >>
>> >> Windows reports a total of 1G of RAM without this commit and the expected
>> >> 2G with this commit.
>> >>
>> >> Signed-off-by: Ladi Prosek 
>> >> ---
>> >>  hw/i386/acpi-build.c | 7 +--
>> >>  1 file changed, 5 insertions(+), 2 deletions(-)
>> >>
>> >> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
>> >> index afcadac..9653583 100644
>> >> --- a/hw/i386/acpi-build.c
>> >> +++ b/hw/i386/acpi-build.c
>> >> @@ -2404,14 +2404,17 @@ build_srat(GArray *table_data, BIOSLinker 
>> >> *linker, MachineState *machine)
>> >>  }
>> >>
>> >>  /*
>> >> - * Entry is required for Windows to enable memory hotplug in OS.
>> >> + * Entry is required for Windows to enable memory hotplug in OS
>> >> + * and for Linux to enable SWIOTLB even if booted with less than
> s/even if/when/
>
>> >> + * 4G of RAM. Windows works better if the entry sets proximity
>> >> + * to the highest NUMA node in the machine.
>> >>   * Memory devices may override proximity set by this entry,
>> >>   * providing _PXM method if necessary.
>> >>   */
>> >>  if (hotplugabble_address_space_size) {
>> >>  numamem = acpi_data_push(table_data, sizeof *numamem);
>> >>  build_srat_memory(numamem, pcms->hotplug_memory.base,
>> >> -  hotplugabble_address_space_size, 0,
>> >> +  hotplugabble_address_space_size, 
>> >> pcms->numa_nodes - 1,
>> >>MEM_AFFINITY_HOTPLUGGABLE | 
>> >> MEM_AFFINITY_ENABLED);
>> >>  }
>> >>
>> >>
>> >
>



Re: [Qemu-devel] [PATCH] pc: ACPI BIOS: use highest NUMA node for hotplug mem hole SRAT entry

2017-05-24 Thread Michael S. Tsirkin
On Wed, May 24, 2017 at 11:16:14AM +0200, Ladi Prosek wrote:
> On Wed, May 24, 2017 at 11:07 AM, Laszlo Ersek  wrote:
> > On 05/24/17 10:09, Ladi Prosek wrote:
> >> For reasons unknown, Windows won't online all memory, both at command
> >> line and hot-plugged later, unless the hotplug mem hole SRAT entry
> >> specifies a node greater or equal to the ones where memory is added.
> >
> > s/greater or equal to/greater *than* or equal to/
> >
> > Thanks,
> > Laszlo
> > (always finding the important issues! ;) )
> 
> Haha, thanks! Igor, please let me know if you'd like me to send a
> corrected version.

Yes and pls include Igor's note to maintainer after --- so I don't
forget.

> >>
> >> Using the highest node on the machine makes recent versions of Windows
> >> happy.
> >>
> >> With this example command line:
> >>   ... \
> >>   -m 1024,slots=4,maxmem=32G \
> >>   -numa node,nodeid=0 \
> >>   -numa node,nodeid=1 \
> >>   -numa node,nodeid=2 \
> >>   -numa node,nodeid=3 \
> >>   -object memory-backend-ram,size=1G,id=mem-mem1 \
> >>   -device pc-dimm,id=dimm-mem1,memdev=mem-mem1,node=1
> >>
> >> Windows reports a total of 1G of RAM without this commit and the expected
> >> 2G with this commit.
> >>
> >> Signed-off-by: Ladi Prosek 
> >> ---
> >>  hw/i386/acpi-build.c | 7 +--
> >>  1 file changed, 5 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> >> index afcadac..9653583 100644
> >> --- a/hw/i386/acpi-build.c
> >> +++ b/hw/i386/acpi-build.c
> >> @@ -2404,14 +2404,17 @@ build_srat(GArray *table_data, BIOSLinker *linker, 
> >> MachineState *machine)
> >>  }
> >>
> >>  /*
> >> - * Entry is required for Windows to enable memory hotplug in OS.
> >> + * Entry is required for Windows to enable memory hotplug in OS
> >> + * and for Linux to enable SWIOTLB even if booted with less than
> >> + * 4G of RAM. Windows works better if the entry sets proximity
> >> + * to the highest NUMA node in the machine.
> >>   * Memory devices may override proximity set by this entry,
> >>   * providing _PXM method if necessary.
> >>   */
> >>  if (hotplugabble_address_space_size) {
> >>  numamem = acpi_data_push(table_data, sizeof *numamem);
> >>  build_srat_memory(numamem, pcms->hotplug_memory.base,
> >> -  hotplugabble_address_space_size, 0,
> >> +  hotplugabble_address_space_size, 
> >> pcms->numa_nodes - 1,
> >>MEM_AFFINITY_HOTPLUGGABLE | 
> >> MEM_AFFINITY_ENABLED);
> >>  }
> >>
> >>
> >



Re: [Qemu-devel] [PATCH] pc: ACPI BIOS: use highest NUMA node for hotplug mem hole SRAT entry

2017-05-24 Thread Igor Mammedov
On Wed, 24 May 2017 11:16:14 +0200
Ladi Prosek  wrote:

> On Wed, May 24, 2017 at 11:07 AM, Laszlo Ersek  wrote:
> > On 05/24/17 10:09, Ladi Prosek wrote:  
> >> For reasons unknown, Windows won't online all memory, both at command
> >> line and hot-plugged later, unless the hotplug mem hole SRAT entry
> >> specifies a node greater or equal to the ones where memory is added.  
> >
> > s/greater or equal to/greater *than* or equal to/
> >
> > Thanks,
> > Laszlo
> > (always finding the important issues! ;) )  
> 
> Haha, thanks! Igor, please let me know if you'd like me to send a
> corrected version.
if you are going to respin see for nit below

also could you check that 'make V=1 check' is happy,
since patch changes SRAT table, bios tables test may fail
if that happen then please add to commit message
you can verify that updating reference blobs fixes make check with
tests/acpi-test-data/rebuild-expected-aml.sh

---
note to maintainer:
tests/acpi-test-data need to be updated due to change in SRAT table

> 
> >>
> >> Using the highest node on the machine makes recent versions of Windows
> >> happy.
> >>
> >> With this example command line:
> >>   ... \
> >>   -m 1024,slots=4,maxmem=32G \
> >>   -numa node,nodeid=0 \
> >>   -numa node,nodeid=1 \
> >>   -numa node,nodeid=2 \
> >>   -numa node,nodeid=3 \
> >>   -object memory-backend-ram,size=1G,id=mem-mem1 \
> >>   -device pc-dimm,id=dimm-mem1,memdev=mem-mem1,node=1
> >>
> >> Windows reports a total of 1G of RAM without this commit and the expected
> >> 2G with this commit.
> >>
> >> Signed-off-by: Ladi Prosek 
> >> ---
> >>  hw/i386/acpi-build.c | 7 +--
> >>  1 file changed, 5 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> >> index afcadac..9653583 100644
> >> --- a/hw/i386/acpi-build.c
> >> +++ b/hw/i386/acpi-build.c
> >> @@ -2404,14 +2404,17 @@ build_srat(GArray *table_data, BIOSLinker *linker, 
> >> MachineState *machine)
> >>  }
> >>
> >>  /*
> >> - * Entry is required for Windows to enable memory hotplug in OS.
> >> + * Entry is required for Windows to enable memory hotplug in OS
> >> + * and for Linux to enable SWIOTLB even if booted with less than
s/even if/when/

> >> + * 4G of RAM. Windows works better if the entry sets proximity
> >> + * to the highest NUMA node in the machine.
> >>   * Memory devices may override proximity set by this entry,
> >>   * providing _PXM method if necessary.
> >>   */
> >>  if (hotplugabble_address_space_size) {
> >>  numamem = acpi_data_push(table_data, sizeof *numamem);
> >>  build_srat_memory(numamem, pcms->hotplug_memory.base,
> >> -  hotplugabble_address_space_size, 0,
> >> +  hotplugabble_address_space_size, 
> >> pcms->numa_nodes - 1,
> >>MEM_AFFINITY_HOTPLUGGABLE | 
> >> MEM_AFFINITY_ENABLED);
> >>  }
> >>
> >>  
> >  




Re: [Qemu-devel] [PATCH] pc: ACPI BIOS: use highest NUMA node for hotplug mem hole SRAT entry

2017-05-24 Thread Ladi Prosek
On Wed, May 24, 2017 at 11:07 AM, Laszlo Ersek  wrote:
> On 05/24/17 10:09, Ladi Prosek wrote:
>> For reasons unknown, Windows won't online all memory, both at command
>> line and hot-plugged later, unless the hotplug mem hole SRAT entry
>> specifies a node greater or equal to the ones where memory is added.
>
> s/greater or equal to/greater *than* or equal to/
>
> Thanks,
> Laszlo
> (always finding the important issues! ;) )

Haha, thanks! Igor, please let me know if you'd like me to send a
corrected version.

>>
>> Using the highest node on the machine makes recent versions of Windows
>> happy.
>>
>> With this example command line:
>>   ... \
>>   -m 1024,slots=4,maxmem=32G \
>>   -numa node,nodeid=0 \
>>   -numa node,nodeid=1 \
>>   -numa node,nodeid=2 \
>>   -numa node,nodeid=3 \
>>   -object memory-backend-ram,size=1G,id=mem-mem1 \
>>   -device pc-dimm,id=dimm-mem1,memdev=mem-mem1,node=1
>>
>> Windows reports a total of 1G of RAM without this commit and the expected
>> 2G with this commit.
>>
>> Signed-off-by: Ladi Prosek 
>> ---
>>  hw/i386/acpi-build.c | 7 +--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
>> index afcadac..9653583 100644
>> --- a/hw/i386/acpi-build.c
>> +++ b/hw/i386/acpi-build.c
>> @@ -2404,14 +2404,17 @@ build_srat(GArray *table_data, BIOSLinker *linker, 
>> MachineState *machine)
>>  }
>>
>>  /*
>> - * Entry is required for Windows to enable memory hotplug in OS.
>> + * Entry is required for Windows to enable memory hotplug in OS
>> + * and for Linux to enable SWIOTLB even if booted with less than
>> + * 4G of RAM. Windows works better if the entry sets proximity
>> + * to the highest NUMA node in the machine.
>>   * Memory devices may override proximity set by this entry,
>>   * providing _PXM method if necessary.
>>   */
>>  if (hotplugabble_address_space_size) {
>>  numamem = acpi_data_push(table_data, sizeof *numamem);
>>  build_srat_memory(numamem, pcms->hotplug_memory.base,
>> -  hotplugabble_address_space_size, 0,
>> +  hotplugabble_address_space_size, pcms->numa_nodes 
>> - 1,
>>MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED);
>>  }
>>
>>
>



Re: [Qemu-devel] [PATCH] pc: ACPI BIOS: use highest NUMA node for hotplug mem hole SRAT entry

2017-05-24 Thread Laszlo Ersek
On 05/24/17 10:09, Ladi Prosek wrote:
> For reasons unknown, Windows won't online all memory, both at command
> line and hot-plugged later, unless the hotplug mem hole SRAT entry
> specifies a node greater or equal to the ones where memory is added.

s/greater or equal to/greater *than* or equal to/

Thanks,
Laszlo
(always finding the important issues! ;) )

> 
> Using the highest node on the machine makes recent versions of Windows
> happy.
> 
> With this example command line:
>   ... \
>   -m 1024,slots=4,maxmem=32G \
>   -numa node,nodeid=0 \
>   -numa node,nodeid=1 \
>   -numa node,nodeid=2 \
>   -numa node,nodeid=3 \
>   -object memory-backend-ram,size=1G,id=mem-mem1 \
>   -device pc-dimm,id=dimm-mem1,memdev=mem-mem1,node=1
> 
> Windows reports a total of 1G of RAM without this commit and the expected
> 2G with this commit.
> 
> Signed-off-by: Ladi Prosek 
> ---
>  hw/i386/acpi-build.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index afcadac..9653583 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -2404,14 +2404,17 @@ build_srat(GArray *table_data, BIOSLinker *linker, 
> MachineState *machine)
>  }
>  
>  /*
> - * Entry is required for Windows to enable memory hotplug in OS.
> + * Entry is required for Windows to enable memory hotplug in OS
> + * and for Linux to enable SWIOTLB even if booted with less than
> + * 4G of RAM. Windows works better if the entry sets proximity
> + * to the highest NUMA node in the machine.
>   * Memory devices may override proximity set by this entry,
>   * providing _PXM method if necessary.
>   */
>  if (hotplugabble_address_space_size) {
>  numamem = acpi_data_push(table_data, sizeof *numamem);
>  build_srat_memory(numamem, pcms->hotplug_memory.base,
> -  hotplugabble_address_space_size, 0,
> +  hotplugabble_address_space_size, pcms->numa_nodes 
> - 1,
>MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED);
>  }
>  
> 




Re: [Qemu-devel] [PATCH] pc: ACPI BIOS: use highest NUMA node for hotplug mem hole SRAT entry

2017-05-24 Thread no-reply
Hi,

This series failed automatic build test. Please find the testing commands and
their output below. If you have docker installed, you can probably reproduce it
locally.

Message-id: 20170524080914.23484-1-lpro...@redhat.com
Subject: [Qemu-devel] [PATCH] pc: ACPI BIOS: use highest NUMA node for hotplug 
mem hole SRAT entry
Type: series

=== TEST SCRIPT BEGIN ===
#!/bin/bash
set -e
git submodule update --init dtc
# Let docker tests dump environment info
export SHOW_ENV=1
export J=8
time make docker-test-quick@centos6
time make docker-test-mingw@fedora
time make docker-test-build@min-glib
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 - [tag update]  patchew/20170524080914.23484-1-lpro...@redhat.com -> 
patchew/20170524080914.23484-1-lpro...@redhat.com
 * [new tag] patchew/20170524083446.32261-1-maxime.coque...@redhat.com 
-> patchew/20170524083446.32261-1-maxime.coque...@redhat.com
Switched to a new branch 'test'
4beffef pc: ACPI BIOS: use highest NUMA node for hotplug mem hole SRAT entry

=== OUTPUT BEGIN ===
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into '/var/tmp/patchew-tester-tmp-git7xdn0/src/dtc'...
Submodule path 'dtc': checked out '558cd81bdd432769b59bff01240c44f82cfb1a9d'
  BUILD   centos6
make[1]: Entering directory '/var/tmp/patchew-tester-tmp-git7xdn0/src'
  ARCHIVE qemu.tgz
  ARCHIVE dtc.tgz
  COPYRUNNER
RUN test-quick in qemu:centos6 
Packages installed:
SDL-devel-1.2.14-7.el6_7.1.x86_64
ccache-3.1.6-2.el6.x86_64
epel-release-6-8.noarch
gcc-4.4.7-17.el6.x86_64
git-1.7.1-4.el6_7.1.x86_64
glib2-devel-2.28.8-5.el6.x86_64
libfdt-devel-1.4.0-1.el6.x86_64
make-3.81-23.el6.x86_64
package g++ is not installed
pixman-devel-0.32.8-1.el6.x86_64
tar-1.23-15.el6_8.x86_64
zlib-devel-1.2.3-29.el6.x86_64

Environment variables:
PACKAGES=libfdt-devel ccache tar git make gcc g++ zlib-devel 
glib2-devel SDL-devel pixman-devel epel-release
HOSTNAME=ceab1df38e0d
TERM=xterm
MAKEFLAGS= -j8
HISTSIZE=1000
J=8
USER=root
CCACHE_DIR=/var/tmp/ccache
EXTRA_CONFIGURE_OPTS=
V=
SHOW_ENV=1
MAIL=/var/spool/mail/root
PATH=/usr/lib/ccache:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/
LANG=en_US.UTF-8
TARGET_LIST=
HISTCONTROL=ignoredups
SHLVL=1
HOME=/root
TEST_DIR=/tmp/qemu-test
LOGNAME=root
LESSOPEN=||/usr/bin/lesspipe.sh %s
FEATURES= dtc
DEBUG=
G_BROKEN_FILENAMES=1
CCACHE_HASHDIR=
_=/usr/bin/env

Configure options:
--enable-werror --target-list=x86_64-softmmu,aarch64-softmmu 
--prefix=/var/tmp/qemu-build/install
No C++ compiler available; disabling C++ specific optional code
Install prefix/var/tmp/qemu-build/install
BIOS directory/var/tmp/qemu-build/install/share/qemu
binary directory  /var/tmp/qemu-build/install/bin
library directory /var/tmp/qemu-build/install/lib
module directory  /var/tmp/qemu-build/install/lib/qemu
libexec directory /var/tmp/qemu-build/install/libexec
include directory /var/tmp/qemu-build/install/include
config directory  /var/tmp/qemu-build/install/etc
local state directory   /var/tmp/qemu-build/install/var
Manual directory  /var/tmp/qemu-build/install/share/man
ELF interp prefix /usr/gnemul/qemu-%M
Source path   /tmp/qemu-test/src
C compilercc
Host C compiler   cc
C++ compiler  
Objective-C compiler cc
ARFLAGS   rv
CFLAGS-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -g 
QEMU_CFLAGS   -I/usr/include/pixman-1   -I$(SRC_PATH)/dtc/libfdt -pthread 
-I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include   -fPIE -DPIE -m64 -mcx16 
-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes 
-Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes 
-fno-strict-aliasing -fno-common -fwrapv  -Wendif-labels 
-Wno-missing-include-dirs -Wempty-body -Wnested-externs -Wformat-security 
-Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration 
-Wold-style-definition -Wtype-limits -fstack-protector-all
LDFLAGS   -Wl,--warn-common -Wl,-z,relro -Wl,-z,now -pie -m64 -g 
make  make
install   install
pythonpython -B
smbd  /usr/sbin/smbd
module supportno
host CPU  x86_64
host big endian   no
target list   x86_64-softmmu aarch64-softmmu
tcg debug enabled no
gprof enabled no
sparse enabledno
strip binariesyes
profiler  no
static build  no
pixmansystem
SDL support   yes (1.2.14)
GTK support   no 
GTK GL supportno
VTE support   no 
TLS priority  NORMAL
GNUTLS supportno
GNUTLS rndno
libgcrypt no
libgcrypt kdf no
nettleno 
nettle kdfno
libtasn1  no
curses supportno
virgl support no
curl support  no
mingw32 support   no
Audio drivers oss
Block whitelist (rw) 
Block whitelist (ro) 
VirtFS supportno
VNC support   yes
VNC SASL support  no
VNC JPEG support  no
V

Re: [Qemu-devel] [PATCH] pc: ACPI BIOS: use highest NUMA node for hotplug mem hole SRAT entry

2017-05-24 Thread Igor Mammedov
On Wed, 24 May 2017 10:09:14 +0200
Ladi Prosek  wrote:

> For reasons unknown, Windows won't online all memory, both at command
> line and hot-plugged later, unless the hotplug mem hole SRAT entry
> specifies a node greater or equal to the ones where memory is added.
> 
> Using the highest node on the machine makes recent versions of Windows
> happy.
> 
> With this example command line:
>   ... \
>   -m 1024,slots=4,maxmem=32G \
>   -numa node,nodeid=0 \
>   -numa node,nodeid=1 \
>   -numa node,nodeid=2 \
>   -numa node,nodeid=3 \
>   -object memory-backend-ram,size=1G,id=mem-mem1 \
>   -device pc-dimm,id=dimm-mem1,memdev=mem-mem1,node=1
> 
> Windows reports a total of 1G of RAM without this commit and the expected
> 2G with this commit.
> 
> Signed-off-by: Ladi Prosek 
Reviewed-by: Igor Mammedov 

> ---
>  hw/i386/acpi-build.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index afcadac..9653583 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -2404,14 +2404,17 @@ build_srat(GArray *table_data, BIOSLinker *linker, 
> MachineState *machine)
>  }
>  
>  /*
> - * Entry is required for Windows to enable memory hotplug in OS.
> + * Entry is required for Windows to enable memory hotplug in OS
> + * and for Linux to enable SWIOTLB even if booted with less than
> + * 4G of RAM. Windows works better if the entry sets proximity
> + * to the highest NUMA node in the machine.
>   * Memory devices may override proximity set by this entry,
>   * providing _PXM method if necessary.
>   */
>  if (hotplugabble_address_space_size) {
>  numamem = acpi_data_push(table_data, sizeof *numamem);
>  build_srat_memory(numamem, pcms->hotplug_memory.base,
> -  hotplugabble_address_space_size, 0,
> +  hotplugabble_address_space_size, pcms->numa_nodes 
> - 1,
>MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED);
>  }
>  




[Qemu-devel] [PATCH] pc: ACPI BIOS: use highest NUMA node for hotplug mem hole SRAT entry

2017-05-24 Thread Ladi Prosek
For reasons unknown, Windows won't online all memory, both at command
line and hot-plugged later, unless the hotplug mem hole SRAT entry
specifies a node greater or equal to the ones where memory is added.

Using the highest node on the machine makes recent versions of Windows
happy.

With this example command line:
  ... \
  -m 1024,slots=4,maxmem=32G \
  -numa node,nodeid=0 \
  -numa node,nodeid=1 \
  -numa node,nodeid=2 \
  -numa node,nodeid=3 \
  -object memory-backend-ram,size=1G,id=mem-mem1 \
  -device pc-dimm,id=dimm-mem1,memdev=mem-mem1,node=1

Windows reports a total of 1G of RAM without this commit and the expected
2G with this commit.

Signed-off-by: Ladi Prosek 
---
 hw/i386/acpi-build.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index afcadac..9653583 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -2404,14 +2404,17 @@ build_srat(GArray *table_data, BIOSLinker *linker, 
MachineState *machine)
 }
 
 /*
- * Entry is required for Windows to enable memory hotplug in OS.
+ * Entry is required for Windows to enable memory hotplug in OS
+ * and for Linux to enable SWIOTLB even if booted with less than
+ * 4G of RAM. Windows works better if the entry sets proximity
+ * to the highest NUMA node in the machine.
  * Memory devices may override proximity set by this entry,
  * providing _PXM method if necessary.
  */
 if (hotplugabble_address_space_size) {
 numamem = acpi_data_push(table_data, sizeof *numamem);
 build_srat_memory(numamem, pcms->hotplug_memory.base,
-  hotplugabble_address_space_size, 0,
+  hotplugabble_address_space_size, pcms->numa_nodes - 
1,
   MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED);
 }
 
-- 
2.9.3