You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
2.4 KiB
70 lines
2.4 KiB
2 months ago
|
From b9d0c78f04160fbc1eee6cfd94b17f1133a35d83 Mon Sep 17 00:00:00 2001
|
||
|
From: Bernhard Beschow <shentey@gmail.com>
|
||
|
Date: Tue, 30 Apr 2024 17:06:38 +0200
|
||
|
Subject: [PATCH 037/100] hw/i386/x86: Eliminate two if statements in
|
||
|
x86_bios_rom_init()
|
||
|
MIME-Version: 1.0
|
||
|
Content-Type: text/plain; charset=UTF-8
|
||
|
Content-Transfer-Encoding: 8bit
|
||
|
|
||
|
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
||
|
RH-MergeRequest: 245: SEV-SNP support
|
||
|
RH-Jira: RHEL-39544
|
||
|
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
||
|
RH-Acked-by: Bandan Das <bdas@redhat.com>
|
||
|
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
|
||
|
RH-Commit: [37/91] 1ef6a13214e85f6ef773f5c894c720f20330912b (bonzini/rhel-qemu-kvm)
|
||
|
|
||
|
Given that memory_region_set_readonly() is a no-op when the readonlyness is
|
||
|
already as requested it is possible to simplify the pattern
|
||
|
|
||
|
if (condition) {
|
||
|
foo(true);
|
||
|
}
|
||
|
|
||
|
to
|
||
|
|
||
|
foo(condition);
|
||
|
|
||
|
which is shorter and allows to see the invariant of the code more easily.
|
||
|
|
||
|
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
|
||
|
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||
|
Message-ID: <20240430150643.111976-2-shentey@gmail.com>
|
||
|
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||
|
(cherry picked from commit 014dbdac8798799d081abc9dff3e4876ca54f49e)
|
||
|
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
||
|
---
|
||
|
hw/i386/x86.c | 8 ++------
|
||
|
1 file changed, 2 insertions(+), 6 deletions(-)
|
||
|
|
||
|
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
|
||
|
index 3d5b51e92d..2a4f3ee285 100644
|
||
|
--- a/hw/i386/x86.c
|
||
|
+++ b/hw/i386/x86.c
|
||
|
@@ -1163,9 +1163,7 @@ void x86_bios_rom_init(MachineState *ms, const char *default_firmware,
|
||
|
load_image_size(filename, ptr, bios_size);
|
||
|
x86_firmware_configure(ptr, bios_size);
|
||
|
} else {
|
||
|
- if (!isapc_ram_fw) {
|
||
|
- memory_region_set_readonly(bios, true);
|
||
|
- }
|
||
|
+ memory_region_set_readonly(bios, !isapc_ram_fw);
|
||
|
ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1);
|
||
|
if (ret != 0) {
|
||
|
goto bios_error;
|
||
|
@@ -1182,9 +1180,7 @@ void x86_bios_rom_init(MachineState *ms, const char *default_firmware,
|
||
|
0x100000 - isa_bios_size,
|
||
|
isa_bios,
|
||
|
1);
|
||
|
- if (!isapc_ram_fw) {
|
||
|
- memory_region_set_readonly(isa_bios, true);
|
||
|
- }
|
||
|
+ memory_region_set_readonly(isa_bios, !isapc_ram_fw);
|
||
|
|
||
|
/* map all the bios at the top of memory */
|
||
|
memory_region_add_subregion(rom_memory,
|
||
|
--
|
||
|
2.39.3
|
||
|
|