Message ID | e9035197-b329-af2e-65ed-af31cd0375c2@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | x86/HVM: tidy _hvm_load_entry() for style | expand |
On 31/07/2023 2:31 pm, Jan Beulich wrote: > The primary goal is to eliminate the Misra-non-compliance of "desc" > shadowing at least the local variable in hvm_load(). Suffix both local > variables with underscores, while also > - dropping leading underscores from parameter names (applying this also > to the two wrapper macros), > - correcting indentation, > - correcting brace placement, > - dropping unnecessary parentheses around parameter uses when those are > passed on as plain arguments. > > No functional change intended. > > Signed-off-by: Jan Beulich <jbeulich@suse.com> > > --- a/xen/arch/x86/include/asm/hvm/save.h > +++ b/xen/arch/x86/include/asm/hvm/save.h > @@ -47,30 +47,32 @@ void _hvm_read_entry(struct hvm_domain_c > * Unmarshalling: check, then copy. Evaluates to zero on success. This load > * function requires the save entry to be the same size as the dest structure. > */ > -#define _hvm_load_entry(_x, _h, _dst, _strict) ({ \ > - int r; \ > - struct hvm_save_descriptor *desc \ > - = (struct hvm_save_descriptor *)&(_h)->data[(_h)->cur]; \ > - if ( (r = _hvm_check_entry((_h), HVM_SAVE_CODE(_x), \ > - HVM_SAVE_LENGTH(_x), (_strict))) == 0 ) \ > +#define _hvm_load_entry(x, h, dst, strict) ({ \ > + int r_; \ > + struct hvm_save_descriptor *desc_ \ > + = (struct hvm_save_descriptor *)&(h)->data[(h)->cur]; \ > + if ( (r_ = _hvm_check_entry(h, HVM_SAVE_CODE(x), \ > + HVM_SAVE_LENGTH(x), strict)) == 0 ) \ > { \ > - _hvm_read_entry((_h), (_dst), HVM_SAVE_LENGTH(_x)); \ > - if ( HVM_SAVE_HAS_COMPAT(_x) && \ > - desc->length != HVM_SAVE_LENGTH(_x) ) \ > - r = HVM_SAVE_FIX_COMPAT(_x, (_dst), desc->length); \ > + _hvm_read_entry(h, dst, HVM_SAVE_LENGTH(x)); \ > + if ( HVM_SAVE_HAS_COMPAT(x) && \ > + desc_->length != HVM_SAVE_LENGTH(x) ) \ > + r_ = HVM_SAVE_FIX_COMPAT(x, dst, desc_->length); \ > } \ > - else if (HVM_SAVE_HAS_COMPAT(_x) \ > - && (r = _hvm_check_entry((_h), HVM_SAVE_CODE(_x), \ > - HVM_SAVE_LENGTH_COMPAT(_x), (_strict))) == 0 ) { \ > - _hvm_read_entry((_h), (_dst), HVM_SAVE_LENGTH_COMPAT(_x)); \ > - r = HVM_SAVE_FIX_COMPAT(_x, (_dst), desc->length); \ > + else if (HVM_SAVE_HAS_COMPAT(x) \ > + && (r_ = _hvm_check_entry(h, HVM_SAVE_CODE(x), \ && on prev line, and an extra space before HVM_SAVE_HAS_COMPAT() With that, Acked-by: Andrew Cooper <andrew.cooper3@citrix.com> This code re-enforces my firm belief that this has no business living in the hypervisor at all. All of this can live in userspace, with a slightly improved hypercall interface. ~Andrew
On Mon, 31 Jul 2023, Jan Beulich wrote: > The primary goal is to eliminate the Misra-non-compliance of "desc" > shadowing at least the local variable in hvm_load(). Suffix both local > variables with underscores, while also > - dropping leading underscores from parameter names (applying this also > to the two wrapper macros), > - correcting indentation, > - correcting brace placement, > - dropping unnecessary parentheses around parameter uses when those are > passed on as plain arguments. you might want (or not want) to mention the s/1/true/ and s/0/false/ > No functional change intended. > > Signed-off-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org> > --- a/xen/arch/x86/include/asm/hvm/save.h > +++ b/xen/arch/x86/include/asm/hvm/save.h > @@ -47,30 +47,32 @@ void _hvm_read_entry(struct hvm_domain_c > * Unmarshalling: check, then copy. Evaluates to zero on success. This load > * function requires the save entry to be the same size as the dest structure. > */ > -#define _hvm_load_entry(_x, _h, _dst, _strict) ({ \ > - int r; \ > - struct hvm_save_descriptor *desc \ > - = (struct hvm_save_descriptor *)&(_h)->data[(_h)->cur]; \ > - if ( (r = _hvm_check_entry((_h), HVM_SAVE_CODE(_x), \ > - HVM_SAVE_LENGTH(_x), (_strict))) == 0 ) \ > +#define _hvm_load_entry(x, h, dst, strict) ({ \ > + int r_; \ > + struct hvm_save_descriptor *desc_ \ > + = (struct hvm_save_descriptor *)&(h)->data[(h)->cur]; \ > + if ( (r_ = _hvm_check_entry(h, HVM_SAVE_CODE(x), \ > + HVM_SAVE_LENGTH(x), strict)) == 0 ) \ > { \ > - _hvm_read_entry((_h), (_dst), HVM_SAVE_LENGTH(_x)); \ > - if ( HVM_SAVE_HAS_COMPAT(_x) && \ > - desc->length != HVM_SAVE_LENGTH(_x) ) \ > - r = HVM_SAVE_FIX_COMPAT(_x, (_dst), desc->length); \ > + _hvm_read_entry(h, dst, HVM_SAVE_LENGTH(x)); \ > + if ( HVM_SAVE_HAS_COMPAT(x) && \ > + desc_->length != HVM_SAVE_LENGTH(x) ) \ > + r_ = HVM_SAVE_FIX_COMPAT(x, dst, desc_->length); \ > } \ > - else if (HVM_SAVE_HAS_COMPAT(_x) \ > - && (r = _hvm_check_entry((_h), HVM_SAVE_CODE(_x), \ > - HVM_SAVE_LENGTH_COMPAT(_x), (_strict))) == 0 ) { \ > - _hvm_read_entry((_h), (_dst), HVM_SAVE_LENGTH_COMPAT(_x)); \ > - r = HVM_SAVE_FIX_COMPAT(_x, (_dst), desc->length); \ > + else if (HVM_SAVE_HAS_COMPAT(x) \ > + && (r_ = _hvm_check_entry(h, HVM_SAVE_CODE(x), \ > + HVM_SAVE_LENGTH_COMPAT(x), \ > + strict)) == 0 ) \ > + { \ > + _hvm_read_entry(h, dst, HVM_SAVE_LENGTH_COMPAT(x)); \ > + r_ = HVM_SAVE_FIX_COMPAT(x, dst, desc_->length); \ > } \ > - r; }) > + r_; }) > > -#define hvm_load_entry(_x, _h, _dst) \ > - _hvm_load_entry(_x, _h, _dst, 1) > -#define hvm_load_entry_zeroextend(_x, _h, _dst) \ > - _hvm_load_entry(_x, _h, _dst, 0) > +#define hvm_load_entry(x, h, dst) \ > + _hvm_load_entry(x, h, dst, true) > +#define hvm_load_entry_zeroextend(x, h, dst) \ > + _hvm_load_entry(x, h, dst, false) > > /* Unmarshalling: what is the instance ID of the next entry? */ > static inline unsigned int hvm_load_instance(const struct hvm_domain_context *h) >
--- a/xen/arch/x86/include/asm/hvm/save.h +++ b/xen/arch/x86/include/asm/hvm/save.h @@ -47,30 +47,32 @@ void _hvm_read_entry(struct hvm_domain_c * Unmarshalling: check, then copy. Evaluates to zero on success. This load * function requires the save entry to be the same size as the dest structure. */ -#define _hvm_load_entry(_x, _h, _dst, _strict) ({ \ - int r; \ - struct hvm_save_descriptor *desc \ - = (struct hvm_save_descriptor *)&(_h)->data[(_h)->cur]; \ - if ( (r = _hvm_check_entry((_h), HVM_SAVE_CODE(_x), \ - HVM_SAVE_LENGTH(_x), (_strict))) == 0 ) \ +#define _hvm_load_entry(x, h, dst, strict) ({ \ + int r_; \ + struct hvm_save_descriptor *desc_ \ + = (struct hvm_save_descriptor *)&(h)->data[(h)->cur]; \ + if ( (r_ = _hvm_check_entry(h, HVM_SAVE_CODE(x), \ + HVM_SAVE_LENGTH(x), strict)) == 0 ) \ { \ - _hvm_read_entry((_h), (_dst), HVM_SAVE_LENGTH(_x)); \ - if ( HVM_SAVE_HAS_COMPAT(_x) && \ - desc->length != HVM_SAVE_LENGTH(_x) ) \ - r = HVM_SAVE_FIX_COMPAT(_x, (_dst), desc->length); \ + _hvm_read_entry(h, dst, HVM_SAVE_LENGTH(x)); \ + if ( HVM_SAVE_HAS_COMPAT(x) && \ + desc_->length != HVM_SAVE_LENGTH(x) ) \ + r_ = HVM_SAVE_FIX_COMPAT(x, dst, desc_->length); \ } \ - else if (HVM_SAVE_HAS_COMPAT(_x) \ - && (r = _hvm_check_entry((_h), HVM_SAVE_CODE(_x), \ - HVM_SAVE_LENGTH_COMPAT(_x), (_strict))) == 0 ) { \ - _hvm_read_entry((_h), (_dst), HVM_SAVE_LENGTH_COMPAT(_x)); \ - r = HVM_SAVE_FIX_COMPAT(_x, (_dst), desc->length); \ + else if (HVM_SAVE_HAS_COMPAT(x) \ + && (r_ = _hvm_check_entry(h, HVM_SAVE_CODE(x), \ + HVM_SAVE_LENGTH_COMPAT(x), \ + strict)) == 0 ) \ + { \ + _hvm_read_entry(h, dst, HVM_SAVE_LENGTH_COMPAT(x)); \ + r_ = HVM_SAVE_FIX_COMPAT(x, dst, desc_->length); \ } \ - r; }) + r_; }) -#define hvm_load_entry(_x, _h, _dst) \ - _hvm_load_entry(_x, _h, _dst, 1) -#define hvm_load_entry_zeroextend(_x, _h, _dst) \ - _hvm_load_entry(_x, _h, _dst, 0) +#define hvm_load_entry(x, h, dst) \ + _hvm_load_entry(x, h, dst, true) +#define hvm_load_entry_zeroextend(x, h, dst) \ + _hvm_load_entry(x, h, dst, false) /* Unmarshalling: what is the instance ID of the next entry? */ static inline unsigned int hvm_load_instance(const struct hvm_domain_context *h)
The primary goal is to eliminate the Misra-non-compliance of "desc" shadowing at least the local variable in hvm_load(). Suffix both local variables with underscores, while also - dropping leading underscores from parameter names (applying this also to the two wrapper macros), - correcting indentation, - correcting brace placement, - dropping unnecessary parentheses around parameter uses when those are passed on as plain arguments. No functional change intended. Signed-off-by: Jan Beulich <jbeulich@suse.com>