since QEMU_CFG_NB_CPUS not going away anytime soon and serves the same purpose as just added "etc/boot-cpus" fw_cfg drop support for "etc/boot-cpus" while this code is not in use yet (i.e. QEMU with "etc/boot-cpus" hasn't been released) and reuse QEMU_CFG_NB_CPUS instead of it.
Signed-off-by: Igor Mammedov imammedo@redhat.com --- corresponding QEMU part has been posted to qemu-devel [PATCH for-2.8 0/2] pc: remove redundant fw_cfg file "etc/boot-cpus" --- src/fw/paravirt.h | 1 - src/fw/paravirt.c | 37 ++++++------------------------------- src/fw/smp.c | 2 +- 3 files changed, 7 insertions(+), 33 deletions(-)
diff --git a/src/fw/paravirt.h b/src/fw/paravirt.h index 6f26fd0..d8eb7c4 100644 --- a/src/fw/paravirt.h +++ b/src/fw/paravirt.h @@ -52,7 +52,6 @@ void qemu_preinit(void); void qemu_platform_setup(void); void qemu_cfg_init(void);
-u16 qemu_init_present_cpus_count(void); u16 qemu_get_present_cpus_count(void);
#endif diff --git a/src/fw/paravirt.c b/src/fw/paravirt.c index 125066d..a3ea152 100644 --- a/src/fw/paravirt.c +++ b/src/fw/paravirt.c @@ -205,6 +205,7 @@ qemu_platform_setup(void) #define QEMU_CFG_UUID 0x02 #define QEMU_CFG_NUMA 0x0d #define QEMU_CFG_BOOT_MENU 0x0e +#define QEMU_CFG_NB_CPUS 0x05 #define QEMU_CFG_MAX_CPUS 0x0f #define QEMU_CFG_FILE_DIR 0x19 #define QEMU_CFG_ARCH_LOCAL 0x8000 @@ -319,40 +320,14 @@ qemu_romfile_add(char *name, int select, int skip, int size) romfile_add(&qfile->file); }
-static int -qemu_romfile_get_fwcfg_entry(char *name, int *select) -{ - struct romfile_s *file = romfile_find(name); - if (!file) - return 0; - struct qemu_romfile_s *qfile; - qfile = container_of(file, struct qemu_romfile_s, file); - if (select) - *select = qfile->select; - return file->size; -} - -static int boot_cpus_sel; -static int boot_cpus_file_sz; - -u16 -qemu_init_present_cpus_count(void) -{ - u16 smp_count = romfile_loadint("etc/boot-cpus", - rtc_read(CMOS_BIOS_SMP_COUNT) + 1); - boot_cpus_file_sz = - qemu_romfile_get_fwcfg_entry("etc/boot-cpus", &boot_cpus_sel); - return smp_count; -} - u16 qemu_get_present_cpus_count(void) { - u16 smp_count; - if (!boot_cpus_file_sz) { - smp_count = rtc_read(CMOS_BIOS_SMP_COUNT) + 1; - } else { - qemu_cfg_read_entry(&smp_count, boot_cpus_sel, boot_cpus_file_sz); + u16 smp_count = 0; + qemu_cfg_read_entry(&smp_count, QEMU_CFG_NB_CPUS, sizeof smp_count); + u16 cmos_cpu_count = rtc_read(CMOS_BIOS_SMP_COUNT) + 1; + if (smp_count < cmos_cpu_count) { + smp_count = cmos_cpu_count; } return smp_count; } diff --git a/src/fw/smp.c b/src/fw/smp.c index bcbad69..46d1da1 100644 --- a/src/fw/smp.c +++ b/src/fw/smp.c @@ -176,7 +176,7 @@ smp_setup(void) return;
MaxCountCPUs = romfile_loadint("etc/max-cpus", 0); - u16 smp_count = qemu_init_present_cpus_count(); + u16 smp_count = qemu_get_present_cpus_count(); if (MaxCountCPUs < smp_count) MaxCountCPUs = smp_count;
On Fri, Nov 11, 2016 at 04:35:15PM +0100, Igor Mammedov wrote:
since QEMU_CFG_NB_CPUS not going away anytime soon and serves the same purpose as just added "etc/boot-cpus" fw_cfg drop support for "etc/boot-cpus" while this code is not in use yet (i.e. QEMU with "etc/boot-cpus" hasn't been released) and reuse QEMU_CFG_NB_CPUS instead of it.
I'm okay with this change. I'd like to get Gerd's comments as well though as the patch is targeted for a stable branch.
-Kevin
On So, 2016-11-13 at 23:05 -0500, Kevin O'Connor wrote:
On Fri, Nov 11, 2016 at 04:35:15PM +0100, Igor Mammedov wrote:
since QEMU_CFG_NB_CPUS not going away anytime soon and serves the same purpose as just added "etc/boot-cpus" fw_cfg drop support for "etc/boot-cpus" while this code is not in use yet (i.e. QEMU with "etc/boot-cpus" hasn't been released) and reuse QEMU_CFG_NB_CPUS instead of it.
I'm okay with this change. I'd like to get Gerd's comments as well though as the patch is targeted for a stable branch.
Looks good to me too. I should have remembered this before as I actually added QEMU_CFG_NB_CPUS support to coreboot ...
Process as usual: commit to qemu first, then seabios (master goes first, then cherry-pick into stable), then update seabios binaries in qemu.
cheers, Gerd
On Tue, 15 Nov 2016 11:36:21 +0100 Gerd Hoffmann kraxel@redhat.com wrote:
On So, 2016-11-13 at 23:05 -0500, Kevin O'Connor wrote:
On Fri, Nov 11, 2016 at 04:35:15PM +0100, Igor Mammedov wrote:
since QEMU_CFG_NB_CPUS not going away anytime soon and serves the same purpose as just added "etc/boot-cpus" fw_cfg drop support for "etc/boot-cpus" while this code is not in use yet (i.e. QEMU with "etc/boot-cpus" hasn't been released) and reuse QEMU_CFG_NB_CPUS instead of it.
I'm okay with this change. I'd like to get Gerd's comments as well though as the patch is targeted for a stable branch.
Looks good to me too. I should have remembered this before as I actually added QEMU_CFG_NB_CPUS support to coreboot ...
I'm sorry for making a mess in the first place, I should have looked more into existing fw_cfg interfaces before adding a new one.
Process as usual: commit to qemu first, then seabios (master goes first, then cherry-pick into stable), then update seabios binaries in qemu.
ok, resubmitted v2 of QEMU side
cheers, Gerd
On Tue, 15 Nov 2016 11:36:21 +0100 Gerd Hoffmann kraxel@redhat.com wrote:
On So, 2016-11-13 at 23:05 -0500, Kevin O'Connor wrote:
On Fri, Nov 11, 2016 at 04:35:15PM +0100, Igor Mammedov wrote:
since QEMU_CFG_NB_CPUS not going away anytime soon and serves the same purpose as just added "etc/boot-cpus" fw_cfg drop support for "etc/boot-cpus" while this code is not in use yet (i.e. QEMU with "etc/boot-cpus" hasn't been released) and reuse QEMU_CFG_NB_CPUS instead of it.
I'm okay with this change. I'd like to get Gerd's comments as well though as the patch is targeted for a stable branch.
Looks good to me too. I should have remembered this before as I actually added QEMU_CFG_NB_CPUS support to coreboot ...
Process as usual: commit to qemu first, then seabios (master goes first, then cherry-pick into stable), then update seabios binaries in qemu.
cheers, Gerd
QEMU part has been merged to master: e3cadac07 pc: fix FW_CFG_NB_CPUS to account for -device added CPUs
Gerd, Could you take care about applying this patch to SeaBIOS (+stable) and updating SeaBIOS blob and QEMU?
On Mon, Nov 21, 2016 at 11:56:35AM +0100, Igor Mammedov wrote:
On Tue, 15 Nov 2016 11:36:21 +0100 Gerd Hoffmann kraxel@redhat.com wrote:
On So, 2016-11-13 at 23:05 -0500, Kevin O'Connor wrote:
On Fri, Nov 11, 2016 at 04:35:15PM +0100, Igor Mammedov wrote:
since QEMU_CFG_NB_CPUS not going away anytime soon and serves the same purpose as just added "etc/boot-cpus" fw_cfg drop support for "etc/boot-cpus" while this code is not in use yet (i.e. QEMU with "etc/boot-cpus" hasn't been released) and reuse QEMU_CFG_NB_CPUS instead of it.
I'm okay with this change. I'd like to get Gerd's comments as well though as the patch is targeted for a stable branch.
Looks good to me too. I should have remembered this before as I actually added QEMU_CFG_NB_CPUS support to coreboot ...
Process as usual: commit to qemu first, then seabios (master goes first, then cherry-pick into stable), then update seabios binaries in qemu.
cheers, Gerd
QEMU part has been merged to master: e3cadac07 pc: fix FW_CFG_NB_CPUS to account for -device added CPUs
Gerd, Could you take care about applying this patch to SeaBIOS (+stable) and updating SeaBIOS blob and QEMU?
FYI, I committed this change to the SeaBIOS master branch.
Thanks, -Kevin
Hi,
QEMU part has been merged to master: e3cadac07 pc: fix FW_CFG_NB_CPUS to account for -device added CPUs
Gerd, Could you take care about applying this patch to SeaBIOS (+stable) and updating SeaBIOS blob and QEMU?
FYI, I committed this change to the SeaBIOS master branch.
1.10-stable branch created, patch cherry-picked. Given that there isn't much else yet in master I'll go tag rel-1.10.1 with only that patch tomorrow, in case there are any objections please speak up now.
cheers, Gerd
On Fri, Nov 11, 2016 at 04:35:15PM +0100, Igor Mammedov wrote:
since QEMU_CFG_NB_CPUS not going away anytime soon and serves the same purpose as just added "etc/boot-cpus" fw_cfg drop support for "etc/boot-cpus" while this code is not in use yet (i.e. QEMU with "etc/boot-cpus" hasn't been released) and reuse QEMU_CFG_NB_CPUS instead of it.
[...]
u16 qemu_get_present_cpus_count(void) {
- u16 smp_count;
- if (!boot_cpus_file_sz) {
smp_count = rtc_read(CMOS_BIOS_SMP_COUNT) + 1;
- } else {
qemu_cfg_read_entry(&smp_count, boot_cpus_sel, boot_cpus_file_sz);
- u16 smp_count = 0;
- qemu_cfg_read_entry(&smp_count, QEMU_CFG_NB_CPUS, sizeof smp_count);
- u16 cmos_cpu_count = rtc_read(CMOS_BIOS_SMP_COUNT) + 1;
- if (smp_count < cmos_cpu_count) {
} return smp_count;smp_count = cmos_cpu_count;
}
Just to confirm the forwards and backwards compatibility here - if the above SeaBIOS code runs on QEMU version pre-2.8 then cmos_cpu_count will always be greater than or equal to QEMU_CFG_NB_CPUS, and if SeaBIOS runs on QEMU >= v2.8 then QEMU_CFG_NB_CPUS will always be greater than or equal to cmos_cpu_count?
-Kevin
P.S. minor nit, but I prefer sizeof treated as a function (ie, sizeof(smp_count) ), but I can fixup on commit.
On Tue, 15 Nov 2016 09:54:47 -0500 "Kevin O'Connor" kevin@koconnor.net wrote:
On Fri, Nov 11, 2016 at 04:35:15PM +0100, Igor Mammedov wrote:
since QEMU_CFG_NB_CPUS not going away anytime soon and serves the same purpose as just added "etc/boot-cpus" fw_cfg drop support for "etc/boot-cpus" while this code is not in use yet (i.e. QEMU with "etc/boot-cpus" hasn't been released) and reuse QEMU_CFG_NB_CPUS instead of it.
[...]
u16 qemu_get_present_cpus_count(void) {
- u16 smp_count;
- if (!boot_cpus_file_sz) {
smp_count = rtc_read(CMOS_BIOS_SMP_COUNT) + 1;
- } else {
qemu_cfg_read_entry(&smp_count, boot_cpus_sel, boot_cpus_file_sz);
- u16 smp_count = 0;
- qemu_cfg_read_entry(&smp_count, QEMU_CFG_NB_CPUS, sizeof smp_count);
- u16 cmos_cpu_count = rtc_read(CMOS_BIOS_SMP_COUNT) + 1;
- if (smp_count < cmos_cpu_count) {
} return smp_count;smp_count = cmos_cpu_count;
}
Just to confirm the forwards and backwards compatibility here - if the above SeaBIOS code runs on QEMU version pre-2.8 then cmos_cpu_count will always be greater than or equal to QEMU_CFG_NB_CPUS, and if SeaBIOS runs on QEMU >= v2.8 then QEMU_CFG_NB_CPUS will always be greater than or equal to cmos_cpu_count?
yep
-Kevin
P.S. minor nit, but I prefer sizeof treated as a function (ie, sizeof(smp_count) ), but I can fixup on commit.
Thanks, I'll try to remember.