diff mbox series

[kvmtool] x86: Fix bios memory size in e820_setup

Message ID SY6P282MB3733A7DAEFD362632DAF4897A3572@SY6P282MB3733.AUSP282.PROD.OUTLOOK.COM (mailing list archive)
State New, archived
Headers show
Series [kvmtool] x86: Fix bios memory size in e820_setup | expand

Commit Message

Sicheng Liu Feb. 21, 2024, 5:28 a.m. UTC
The memory region of MB_BIOS is [MB_BIOS_BEGIN, MB_BIOS_END],
so its memory size should be MB_BIOS_END - MB_BIOS_BEGIN + 1.

Signed-off-by: Sicheng Liu <lsc2001@outlook.com>
---
 x86/bios.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Will Deacon March 4, 2024, 2:08 p.m. UTC | #1
On Wed, Feb 21, 2024 at 05:28:43AM +0000, Sicheng Liu wrote:
> The memory region of MB_BIOS is [MB_BIOS_BEGIN, MB_BIOS_END],
> so its memory size should be MB_BIOS_END - MB_BIOS_BEGIN + 1.
> 
> Signed-off-by: Sicheng Liu <lsc2001@outlook.com>
> ---
>  x86/bios.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/x86/bios.c b/x86/bios.c
> index 5ac9e24ae0a8..380e0aba7129 100644
> --- a/x86/bios.c
> +++ b/x86/bios.c
> @@ -75,7 +75,7 @@ static void e820_setup(struct kvm *kvm)
>  	};
>  	mem_map[i++]	= (struct e820entry) {
>  		.addr		= MB_BIOS_BEGIN,
> -		.size		= MB_BIOS_END - MB_BIOS_BEGIN,
> +		.size		= MB_BIOS_END - MB_BIOS_BEGIN + 1,

Use MB_BIOS_SIZE for this?

Even with that, there are a whole bunch of suspicious-looking memset()s
in setup_bios() that probably need similar treatment.

Will
diff mbox series

Patch

diff --git a/x86/bios.c b/x86/bios.c
index 5ac9e24ae0a8..380e0aba7129 100644
--- a/x86/bios.c
+++ b/x86/bios.c
@@ -75,7 +75,7 @@  static void e820_setup(struct kvm *kvm)
 	};
 	mem_map[i++]	= (struct e820entry) {
 		.addr		= MB_BIOS_BEGIN,
-		.size		= MB_BIOS_END - MB_BIOS_BEGIN,
+		.size		= MB_BIOS_END - MB_BIOS_BEGIN + 1,
 		.type		= E820_RESERVED,
 	};
 	if (kvm->ram_size < KVM_32BIT_GAP_START) {