|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v1 3/3] xen/domain: rewrite emulation_flags_ok()
From: Denis Mukhin <dmukhin@xxxxxxxx>
Rewrite emulation_flags_ok() using XEN_X86_EMU_{OPTIONAL,BASELINE}
to simplify future modifications.
Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>
---
Came in the context of NS16550 emulator v3 series:
https://lore.kernel.org/xen-devel/20250103-vuart-ns8250-v3-v1-0-c5d36b31d66c@xxxxxxxx/
After modifying emulation_flags_ok() with a new NS16550 vUART
configuration switch passed from the toolstack for the HVM
case, I decided to look into how to improve emulation_flags_ok().
---
xen/arch/x86/domain.c | 29 +++++++++++------------------
1 file changed, 11 insertions(+), 18 deletions(-)
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 15c5e2a652..23051bb176 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -750,25 +750,18 @@ static bool emulation_flags_ok(const struct domain *d,
uint32_t emflags)
BUILD_BUG_ON(X86_EMU_ALL != XEN_X86_EMU_ALL);
#endif
- if ( is_hvm_domain(d) )
- {
- if ( is_hardware_domain(d) &&
- emflags != (X86_EMU_VPCI | X86_EMU_LAPIC | X86_EMU_IOAPIC) )
- return false;
- if ( !is_hardware_domain(d) &&
- /* HVM PIRQ feature is user-selectable. */
- (emflags & ~X86_EMU_USE_PIRQ) !=
- (X86_EMU_ALL & ~(X86_EMU_VPCI | X86_EMU_USE_PIRQ)) &&
- emflags != X86_EMU_LAPIC )
- return false;
- }
- else if ( emflags != 0 && emflags != X86_EMU_PIT )
- {
- /* PV or classic PVH. */
- return false;
- }
+ /* PV or classic PVH */
+ if ( !is_hvm_domain(d) )
+ return emflags == 0 || emflags == XEN_X86_EMU_PIT;
- return true;
+ /* HVM */
+ if ( is_hardware_domain(d) )
+ return emflags == (XEN_X86_EMU_LAPIC |
+ XEN_X86_EMU_IOAPIC |
+ XEN_X86_EMU_VPCI);
+
+ return (emflags & ~XEN_X86_EMU_OPTIONAL) == XEN_X86_EMU_BASELINE ||
+ emflags == XEN_X86_EMU_LAPIC;
}
void __init arch_init_idle_domain(struct domain *d)
--
2.34.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |