The automatically generated hypercall dispatch logic looks like:
case __HYPERVISOR_update_descriptor: \
ret = do_update_descriptor((uint64_t)(a1), (seg_desc_t)(a2)); \
break; \
but seg_desc_t is a union and Eclair considers this to be a violation of MISRA
Rule 1.1. There's also a Rule 8.3 violation for the parameter name mismatch.
Instead of playing games trying to change seg_desc_t to be a struct, or to
alter the AWK generator to know that seg_desc_t is magic and needs braces
rather than brackets, just switch the type to be a plain uint64_t.
The size is fixed by the x86 architecture, so it is never going to change.
This even lets us simplify compat_update_descriptor() a little.
No functional change.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: consulting@bugseng.com <consulting@bugseng.com>
CC: Nicola Vetrini <nicola.vetrini@bugseng.com>
---
xen/arch/x86/pv/descriptor-tables.c | 10 ++++------
xen/include/hypercall-defs.c | 2 +-
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/xen/arch/x86/pv/descriptor-tables.c b/xen/arch/x86/pv/descriptor-tables.c
index 26f7d18b11b5..8a32b9ae5ced 100644
--- a/xen/arch/x86/pv/descriptor-tables.c
+++ b/xen/arch/x86/pv/descriptor-tables.c
@@ -179,11 +179,8 @@ int compat_set_gdt(
int compat_update_descriptor(
uint32_t pa_lo, uint32_t pa_hi, uint32_t desc_lo, uint32_t desc_hi)
{
- seg_desc_t d;
-
- d.raw = ((uint64_t)desc_hi << 32) | desc_lo;
-
- return do_update_descriptor(pa_lo | ((uint64_t)pa_hi << 32), d);
+ return do_update_descriptor(pa_lo | ((uint64_t)pa_hi << 32),
+ desc_lo | ((uint64_t)desc_hi << 32));
}
#endif /* CONFIG_PV32 */
@@ -288,9 +285,10 @@ int validate_segdesc_page(struct page_info *page)
return i == 512 ? 0 : -EINVAL;
}
-long do_update_descriptor(uint64_t gaddr, seg_desc_t d)
+long do_update_descriptor(uint64_t gaddr, uint64_t desc)
{
struct domain *currd = current->domain;
+ seg_desc_t d = { .raw = desc };
gfn_t gfn = gaddr_to_gfn(gaddr);
mfn_t mfn;
seg_desc_t *entry;
diff --git a/xen/include/hypercall-defs.c b/xen/include/hypercall-defs.c
index cef08eeec1b8..5782cdfd1496 100644
--- a/xen/include/hypercall-defs.c
+++ b/xen/include/hypercall-defs.c
@@ -184,7 +184,7 @@ mca(xen_mc_t *u_xen_mc)
set_trap_table(const_trap_info_t *traps)
set_gdt(xen_ulong_t *frame_list, unsigned int entries)
set_callbacks(unsigned long event_address, unsigned long failsafe_address, unsigned long syscall_address)
-update_descriptor(uint64_t gaddr, seg_desc_t desc)
+update_descriptor(uint64_t gaddr, uint64_t desc)
update_va_mapping(unsigned long va, uint64_t val64, unsigned long flags)
update_va_mapping_otherdomain(unsigned long va, uint64_t val64, unsigned long flags, domid_t domid)
#endif
--
2.39.5