mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] kvm: x86: use a uapi-friendly macro for BIT
@ 2023-12-07  0:11 Dionna Glaze
  2023-12-12 15:27 ` Sean Christopherson
  0 siblings, 1 reply; 3+ messages in thread
From: Dionna Glaze @ 2023-12-07  0:11 UTC (permalink / raw)
  To: kvm, linux-kernel, x86, seanjc, pbonzini; +Cc: Dionna Glaze

Change uapi header uses of BIT to instead use the uapi/linux/const.h bit
macros, since BIT is not defined in uapi headers.

The PMU mask uses _BITUL since it targets a 32 bit flag field, whereas
the longmode definition is meant for a 64 bit flag field.

Cc: Sean Christophersen <seanjc@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>

Signed-off-by: Dionna Glaze <dionnaglaze@google.com>
---
 arch/x86/include/uapi/asm/kvm.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/uapi/asm/kvm.h b/arch/x86/include/uapi/asm/kvm.h
index 1a6a1f987949..a8955efeef09 100644
--- a/arch/x86/include/uapi/asm/kvm.h
+++ b/arch/x86/include/uapi/asm/kvm.h
@@ -7,6 +7,7 @@
  *
  */
 
+#include <linux/const.h>
 #include <linux/types.h>
 #include <linux/ioctl.h>
 #include <linux/stddef.h>
@@ -526,7 +527,7 @@ struct kvm_pmu_event_filter {
 #define KVM_PMU_EVENT_ALLOW 0
 #define KVM_PMU_EVENT_DENY 1
 
-#define KVM_PMU_EVENT_FLAG_MASKED_EVENTS BIT(0)
+#define KVM_PMU_EVENT_FLAG_MASKED_EVENTS _BITUL(0)
 #define KVM_PMU_EVENT_FLAGS_VALID_MASK (KVM_PMU_EVENT_FLAG_MASKED_EVENTS)
 
 /*
@@ -560,6 +561,6 @@ struct kvm_pmu_event_filter {
 #define   KVM_VCPU_TSC_OFFSET 0 /* attribute for the TSC offset */
 
 /* x86-specific KVM_EXIT_HYPERCALL flags. */
-#define KVM_EXIT_HYPERCALL_LONG_MODE	BIT(0)
+#define KVM_EXIT_HYPERCALL_LONG_MODE	_BITULL(0)
 
 #endif /* _ASM_X86_KVM_H */
-- 
2.43.0.rc2.451.g8631bc7472-goog


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] kvm: x86: use a uapi-friendly macro for BIT
  2023-12-07  0:11 [PATCH] kvm: x86: use a uapi-friendly macro for BIT Dionna Glaze
@ 2023-12-12 15:27 ` Sean Christopherson
  2023-12-12 16:07   ` Paolo Bonzini
  0 siblings, 1 reply; 3+ messages in thread
From: Sean Christopherson @ 2023-12-12 15:27 UTC (permalink / raw)
  To: Dionna Glaze; +Cc: kvm, linux-kernel, x86, pbonzini

On Thu, Dec 07, 2023, Dionna Glaze wrote:
> Change uapi header uses of BIT to instead use the uapi/linux/const.h bit
> macros, since BIT is not defined in uapi headers.
> 
> The PMU mask uses _BITUL since it targets a 32 bit flag field, whereas
> the longmode definition is meant for a 64 bit flag field.
> 
> Cc: Sean Christophersen <seanjc@google.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> 
> Signed-off-by: Dionna Glaze <dionnaglaze@google.com>
> ---
>  arch/x86/include/uapi/asm/kvm.h | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/include/uapi/asm/kvm.h b/arch/x86/include/uapi/asm/kvm.h
> index 1a6a1f987949..a8955efeef09 100644
> --- a/arch/x86/include/uapi/asm/kvm.h
> +++ b/arch/x86/include/uapi/asm/kvm.h
> @@ -7,6 +7,7 @@
>   *
>   */
>  
> +#include <linux/const.h>
>  #include <linux/types.h>
>  #include <linux/ioctl.h>
>  #include <linux/stddef.h>
> @@ -526,7 +527,7 @@ struct kvm_pmu_event_filter {
>  #define KVM_PMU_EVENT_ALLOW 0
>  #define KVM_PMU_EVENT_DENY 1
>  
> -#define KVM_PMU_EVENT_FLAG_MASKED_EVENTS BIT(0)
> +#define KVM_PMU_EVENT_FLAG_MASKED_EVENTS _BITUL(0)

It's not just BIT(), won't BIT_ULL() and GENMASK_ULL() also be problematic?  And
sadly, I don't see an existing equivalent for GENMASK_ULL().

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] kvm: x86: use a uapi-friendly macro for BIT
  2023-12-12 15:27 ` Sean Christopherson
@ 2023-12-12 16:07   ` Paolo Bonzini
  0 siblings, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2023-12-12 16:07 UTC (permalink / raw)
  To: Sean Christopherson, Dionna Glaze; +Cc: kvm, linux-kernel, x86

On 12/12/23 16:27, Sean Christopherson wrote:
>> -#define KVM_PMU_EVENT_FLAG_MASKED_EVENTS BIT(0)
>> +#define KVM_PMU_EVENT_FLAG_MASKED_EVENTS _BITUL(0)
> It's not just BIT(), won't BIT_ULL() and GENMASK_ULL() also be problematic?  And
> sadly, I don't see an existing equivalent for GENMASK_ULL().

BIT_ULL() is easy enough, as you point out:

@@ -550,7 +550,7 @@ struct kvm_pmu_event_filter {
         (GENMASK_ULL(7, 0) | GENMASK_ULL(35, 32))
  #define KVM_PMU_MASKED_ENTRY_UMASK_MASK                (GENMASK_ULL(63, 56))
  #define KVM_PMU_MASKED_ENTRY_UMASK_MATCH       (GENMASK_ULL(15, 8))
-#define KVM_PMU_MASKED_ENTRY_EXCLUDE           (BIT_ULL(55))
+#define KVM_PMU_MASKED_ENTRY_EXCLUDE           (_BITULL(55))
  #define KVM_PMU_MASKED_ENTRY_UMASK_MASK_SHIFT  (56)

  /* for KVM_{GET,SET,HAS}_DEVICE_ATTR */

And I'll squash it into Dionna's patch since she has already a conversion
for KVM_EXIT_HYPERCALL_LONG_MODE.  For the others, I'll send a patch.

Paolo


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-12 16:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-07  0:11 [PATCH] kvm: x86: use a uapi-friendly macro for BIT Dionna Glaze
2023-12-12 15:27 ` Sean Christopherson
2023-12-12 16:07   ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®