* Is BIT() in arch/x86/include/uapi/asm/kvm.h defined? Where?
@ 2016-05-05 0:49 Brooks Moses
2016-05-05 8:24 ` Borislav Petkov
0 siblings, 1 reply; 8+ messages in thread
From: Brooks Moses @ 2016-05-05 0:49 UTC (permalink / raw)
To: linux-kernel; +Cc: Ian Kasprzak, Paolo Bonzini, Borislav Petkov
Hello!
Ian and I have run into what looks like a bug in
arch/x86/include/uapi/asm/kvm.h, but it also looks so obvious that we
surely must be doing something wrong. So I request enlightenment.
We discovered this problem on the 4.5.2 release, but the relevant code
appears unchanged from 2013 until current trunk.
When I run "make ARCH=x86 headers_install", and then write a simple C
file that #includes "asm/kvm.h" from the resulting tree, I get a
compiler error: the BIT() macro used on line 219 of that file is
undefined:
https://github.com/torvalds/linux/blob/master/arch/x86/include/uapi/asm/kvm.h#L219
I attempted to find where it was supposed to be defined, and the only
match for "define BIT(" in the whole tree is in
include/linux/bitops.h:
https://github.com/torvalds/linux/blob/master/include/linux/bitops.h#L6
However, that's not in a "uapi" directory, and it's not listed in
include/uapi/linux/Kbuild, so "make headers_install" doesn't install
it. Further, kvm.h doesn't reference it with a #include, so even if
it were installed, it wouldn't be included.
It seems that we must be missing something obvious. But what?
Thanks,
- Brooks
P.S. The change that appears to have added this reference is this
one, signed-off-on by Borislav and Paolo, which is why I've added you
to the cc line.
https://github.com/torvalds/linux/commit/9c15bb1d0a8411f9bb3395d21d5309bde7da0c1c
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Is BIT() in arch/x86/include/uapi/asm/kvm.h defined? Where?
2016-05-05 0:49 Is BIT() in arch/x86/include/uapi/asm/kvm.h defined? Where? Brooks Moses
@ 2016-05-05 8:24 ` Borislav Petkov
2016-05-05 19:15 ` Brooks Moses
2016-05-09 14:00 ` Paolo Bonzini
0 siblings, 2 replies; 8+ messages in thread
From: Borislav Petkov @ 2016-05-05 8:24 UTC (permalink / raw)
To: Brooks Moses; +Cc: linux-kernel, Ian Kasprzak, Paolo Bonzini
On Wed, May 04, 2016 at 05:49:27PM -0700, Brooks Moses wrote:
> When I run "make ARCH=x86 headers_install", and then write a simple C
> file that #includes "asm/kvm.h" from the resulting tree, I get a
> compiler error: the BIT() macro used on line 219 of that file is
> undefined:
The below patch should help...
@Paulo: btw, any chance we can fix that "signifcant" typo :-) in
KVM_CPUID_FLAG_SIGNIFCANT_INDEX or is it user-visible and cast in
stone?
---
From: Borislav Petkov <bp@suse.de>
Date: Thu, 5 May 2016 10:18:23 +0200
Subject: [PATCH] x86/kvm: Do not use BIT() in user-exported header
Apparently, we're not exporting BIT() to userspace.
Reported-by: Brooks Moses <bmoses@google.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Paolo Bonzini <pbonzini@redhat.com>
---
arch/x86/include/uapi/asm/kvm.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/x86/include/uapi/asm/kvm.h b/arch/x86/include/uapi/asm/kvm.h
index cd54147cb365..739c0c594022 100644
--- a/arch/x86/include/uapi/asm/kvm.h
+++ b/arch/x86/include/uapi/asm/kvm.h
@@ -216,9 +216,9 @@ struct kvm_cpuid_entry2 {
__u32 padding[3];
};
-#define KVM_CPUID_FLAG_SIGNIFCANT_INDEX BIT(0)
-#define KVM_CPUID_FLAG_STATEFUL_FUNC BIT(1)
-#define KVM_CPUID_FLAG_STATE_READ_NEXT BIT(2)
+#define KVM_CPUID_FLAG_SIGNIFCANT_INDEX (1 << 0)
+#define KVM_CPUID_FLAG_STATEFUL_FUNC (1 << 1)
+#define KVM_CPUID_FLAG_STATE_READ_NEXT (1 << 2)
/* for KVM_SET_CPUID2 */
struct kvm_cpuid2 {
--
2.7.3
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
--
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: Is BIT() in arch/x86/include/uapi/asm/kvm.h defined? Where?
2016-05-05 8:24 ` Borislav Petkov
@ 2016-05-05 19:15 ` Brooks Moses
2016-05-09 14:00 ` Paolo Bonzini
1 sibling, 0 replies; 8+ messages in thread
From: Brooks Moses @ 2016-05-05 19:15 UTC (permalink / raw)
To: Borislav Petkov; +Cc: linux-kernel, Ian Kasprzak, Paolo Bonzini
On Thu, May 5, 2016 at 1:24 AM, Borislav Petkov <bp@suse.de> wrote:
> On Wed, May 04, 2016 at 05:49:27PM -0700, Brooks Moses wrote:
>> When I run "make ARCH=x86 headers_install", and then write a simple C
>> file that #includes "asm/kvm.h" from the resulting tree, I get a
>> compiler error: the BIT() macro used on line 219 of that file is
>> undefined:
>
> The below patch should help...
Thanks for the quick reply! Yes, this should fix things for us -- and
answers my implicit question of whether it was better to fix this by
avoiding the macro or whether bitops.h was expected to be exported.
> @Paulo: btw, any chance we can fix that "signifcant" typo :-) in
> KVM_CPUID_FLAG_SIGNIFCANT_INDEX or is it user-visible and cast in
> stone?
It's user-visible, but since it's been defined to something that
doesn't work in user-space, it seems unlikely to me that it has any
actual users....
- Brooks
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Is BIT() in arch/x86/include/uapi/asm/kvm.h defined? Where?
2016-05-05 8:24 ` Borislav Petkov
2016-05-05 19:15 ` Brooks Moses
@ 2016-05-09 14:00 ` Paolo Bonzini
2016-05-09 14:47 ` Radim Krčmář
1 sibling, 1 reply; 8+ messages in thread
From: Paolo Bonzini @ 2016-05-09 14:00 UTC (permalink / raw)
To: Borislav Petkov, Brooks Moses
Cc: linux-kernel, Ian Kasprzak, Radim Krčmář
On 05/05/2016 10:24, Borislav Petkov wrote:
> On Wed, May 04, 2016 at 05:49:27PM -0700, Brooks Moses wrote:
>> When I run "make ARCH=x86 headers_install", and then write a simple C
>> file that #includes "asm/kvm.h" from the resulting tree, I get a
>> compiler error: the BIT() macro used on line 219 of that file is
>> undefined:
>
> The below patch should help...
>
> @Paulo: btw, any chance we can fix that "signifcant" typo :-) in
> KVM_CPUID_FLAG_SIGNIFCANT_INDEX or is it user-visible and cast in
> stone?
Unfortuntely it is cast in stone. The patch below is good though.
Radim, please commit it
(http://article.gmane.org/gmane.linux.kernel/2215443/raw) or pass the
tree back to me so that I can. :)
Thanks,
Paolo
> ---
> From: Borislav Petkov <bp@suse.de>
> Date: Thu, 5 May 2016 10:18:23 +0200
> Subject: [PATCH] x86/kvm: Do not use BIT() in user-exported header
>
> Apparently, we're not exporting BIT() to userspace.
>
> Reported-by: Brooks Moses <bmoses@google.com>
> Signed-off-by: Borislav Petkov <bp@suse.de>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> ---
> arch/x86/include/uapi/asm/kvm.h | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/include/uapi/asm/kvm.h b/arch/x86/include/uapi/asm/kvm.h
> index cd54147cb365..739c0c594022 100644
> --- a/arch/x86/include/uapi/asm/kvm.h
> +++ b/arch/x86/include/uapi/asm/kvm.h
> @@ -216,9 +216,9 @@ struct kvm_cpuid_entry2 {
> __u32 padding[3];
> };
>
> -#define KVM_CPUID_FLAG_SIGNIFCANT_INDEX BIT(0)
> -#define KVM_CPUID_FLAG_STATEFUL_FUNC BIT(1)
> -#define KVM_CPUID_FLAG_STATE_READ_NEXT BIT(2)
> +#define KVM_CPUID_FLAG_SIGNIFCANT_INDEX (1 << 0)
> +#define KVM_CPUID_FLAG_STATEFUL_FUNC (1 << 1)
> +#define KVM_CPUID_FLAG_STATE_READ_NEXT (1 << 2)
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
> /* for KVM_SET_CPUID2 */
> struct kvm_cpuid2 {
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Is BIT() in arch/x86/include/uapi/asm/kvm.h defined? Where?
2016-05-09 14:00 ` Paolo Bonzini
@ 2016-05-09 14:47 ` Radim Krčmář
2016-05-09 15:15 ` Paolo Bonzini
0 siblings, 1 reply; 8+ messages in thread
From: Radim Krčmář @ 2016-05-09 14:47 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: Borislav Petkov, Brooks Moses, linux-kernel, Ian Kasprzak
2016-05-09 16:00+0200, Paolo Bonzini:
> On 05/05/2016 10:24, Borislav Petkov wrote:
>> On Wed, May 04, 2016 at 05:49:27PM -0700, Brooks Moses wrote:
>>> When I run "make ARCH=x86 headers_install", and then write a simple C
>>> file that #includes "asm/kvm.h" from the resulting tree, I get a
>>> compiler error: the BIT() macro used on line 219 of that file is
>>> undefined:
>>
>> The below patch should help...
>>
>> @Paulo: btw, any chance we can fix that "signifcant" typo :-) in
>> KVM_CPUID_FLAG_SIGNIFCANT_INDEX or is it user-visible and cast in
>> stone?
>
> Unfortuntely it is cast in stone. The patch below is good though.
We can "fix" it by introducing a second name for the entry. Do you
think it's worth?
> Radim, please commit it
> (http://article.gmane.org/gmane.linux.kernel/2215443/raw) or pass the
> tree back to me so that I can. :)
I've committed the patch. The tree is yours now -- there probably is a
lot I missed ...
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Is BIT() in arch/x86/include/uapi/asm/kvm.h defined? Where?
2016-05-09 14:47 ` Radim Krčmář
@ 2016-05-09 15:15 ` Paolo Bonzini
2016-05-09 15:25 ` Radim Krčmář
0 siblings, 1 reply; 8+ messages in thread
From: Paolo Bonzini @ 2016-05-09 15:15 UTC (permalink / raw)
To: Radim Krčmář
Cc: Borislav Petkov, Brooks Moses, linux-kernel, Ian Kasprzak
On 09/05/2016 16:47, Radim Krčmář wrote:
> 2016-05-09 16:00+0200, Paolo Bonzini:
>> On 05/05/2016 10:24, Borislav Petkov wrote:
>>> On Wed, May 04, 2016 at 05:49:27PM -0700, Brooks Moses wrote:
>>>> When I run "make ARCH=x86 headers_install", and then write a simple C
>>>> file that #includes "asm/kvm.h" from the resulting tree, I get a
>>>> compiler error: the BIT() macro used on line 219 of that file is
>>>> undefined:
>>>
>>> The below patch should help...
>>>
>>> @Paulo: btw, any chance we can fix that "signifcant" typo :-) in
>>> KVM_CPUID_FLAG_SIGNIFCANT_INDEX or is it user-visible and cast in
>>> stone?
>>
>> Unfortuntely it is cast in stone. The patch below is good though.
>
> We can "fix" it by introducing a second name for the entry. Do you
> think it's worth?
I don't think so, but perhaps there are precedents for doing that?
>> Radim, please commit it
>> (http://article.gmane.org/gmane.linux.kernel/2215443/raw) or pass the
>> tree back to me so that I can. :)
>
> I've committed the patch. The tree is yours now -- there probably is a
> lot I missed ...
No problem, I "only" have 1300 messages to go in my inbox but I'll take
a closer look at those that you didn't reply to.
Thanks,
Paolo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Is BIT() in arch/x86/include/uapi/asm/kvm.h defined? Where?
2016-05-09 15:15 ` Paolo Bonzini
@ 2016-05-09 15:25 ` Radim Krčmář
2016-05-09 15:46 ` Borislav Petkov
0 siblings, 1 reply; 8+ messages in thread
From: Radim Krčmář @ 2016-05-09 15:25 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: Borislav Petkov, Brooks Moses, linux-kernel, Ian Kasprzak
2016-05-09 17:15+0200, Paolo Bonzini:
> On 09/05/2016 16:47, Radim Krčmář wrote:
>> 2016-05-09 16:00+0200, Paolo Bonzini:
>>> On 05/05/2016 10:24, Borislav Petkov wrote:
>>>> On Wed, May 04, 2016 at 05:49:27PM -0700, Brooks Moses wrote:
>>>>> When I run "make ARCH=x86 headers_install", and then write a simple C
>>>>> file that #includes "asm/kvm.h" from the resulting tree, I get a
>>>>> compiler error: the BIT() macro used on line 219 of that file is
>>>>> undefined:
>>>>
>>>> The below patch should help...
>>>>
>>>> @Paulo: btw, any chance we can fix that "signifcant" typo :-) in
>>>> KVM_CPUID_FLAG_SIGNIFCANT_INDEX or is it user-visible and cast in
>>>> stone?
>>>
>>> Unfortuntely it is cast in stone. The patch below is good though.
>>
>> We can "fix" it by introducing a second name for the entry. Do you
>> think it's worth?
>
> I don't think so, but perhaps there are precedents for doing that?
I can't think of any, and it seems pointless to me ...
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Is BIT() in arch/x86/include/uapi/asm/kvm.h defined? Where?
2016-05-09 15:25 ` Radim Krčmář
@ 2016-05-09 15:46 ` Borislav Petkov
0 siblings, 0 replies; 8+ messages in thread
From: Borislav Petkov @ 2016-05-09 15:46 UTC (permalink / raw)
To: Radim Krčmář
Cc: Paolo Bonzini, Brooks Moses, linux-kernel, Ian Kasprzak
On Mon, May 09, 2016 at 05:25:02PM +0200, Radim Krčmář wrote:
> I can't think of any, and it seems pointless to me ...
Yeah, f'get it - there are more examples for this like "umount" instead
of "unmount", etc... :-P
What's done is done.
--
Regards/Gruss,
Boris.
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
--
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-05-09 15:46 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-05 0:49 Is BIT() in arch/x86/include/uapi/asm/kvm.h defined? Where? Brooks Moses
2016-05-05 8:24 ` Borislav Petkov
2016-05-05 19:15 ` Brooks Moses
2016-05-09 14:00 ` Paolo Bonzini
2016-05-09 14:47 ` Radim Krčmář
2016-05-09 15:15 ` Paolo Bonzini
2016-05-09 15:25 ` Radim Krčmář
2016-05-09 15:46 ` Borislav Petkov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.