From: Jan Kiszka <jan.kiszka@web.de>
To: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>, kvm@vger.kernel.org
Subject: [PATCH] KVM: x86: Fix 32-bit build breakage due to typo
Date: Sat, 20 Mar 2010 10:14:13 +0100 [thread overview]
Message-ID: <4BA491E5.4090500@web.de> (raw)
In-Reply-To: <4BA08D39.5030005@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2726 bytes --]
Avi Kivity wrote:
> On 03/17/2010 09:45 AM, Jan Kiszka wrote:
>> Avi Kivity wrote:
>>
>>> Once upon a time, locked operations were emulated while holding the
>>> mmu mutex.
>>> Since mmu pages were write protected, it was safe to emulate the
>>> writes in
>>> a non-atomic manner, since there could be no other writer, either in the
>>> guest or in the kernel.
>>>
>>> These days emulation takes place without holding the mmu spinlock, so
>>> the
>>> write could be preempted by an unshadowing event, which exposes the page
>>> to writes by the guest. This may cause corruption of guest page tables.
>>>
>>> Fix by using an atomic cmpxchg for these operations.
>>>
>>> Signed-off-by: Avi Kivity<avi@redhat.com>
>>> ---
>>> arch/x86/kvm/x86.c | 69
>>> ++++++++++++++++++++++++++++++++++++----------------
>>> 1 files changed, 48 insertions(+), 21 deletions(-)
>>>
>>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
>>> index 9d02cc7..d724a52 100644
>>> --- a/arch/x86/kvm/x86.c
>>> +++ b/arch/x86/kvm/x86.c
>>> @@ -3299,41 +3299,68 @@ int emulator_write_emulated(unsigned long addr,
>>> }
>>> EXPORT_SYMBOL_GPL(emulator_write_emulated);
>>>
>>> +#define CMPXCHG_TYPE(t, ptr, old, new) \
>>> + (cmpxchg((t *)(ptr), *(t *)(old), *(t *)(new)) == *(t *)(old))
>>> +
>>> +#ifdef CONFIG_X86_64
>>> +# define CMPXCHG64(ptr, old, new) CMPXCHG_TYPE(u64, ptr, old, new)
>>> +#else
>>> +# define CMPXCHG64(ptr, old, new) \
>>> + (cmpxchg64((u64 *)(ptr), *(u64 *)(old), *(u *)(new)) == *(u64
>>> *)(old))
>>>
>> ^^^^^^
>> This should cause the 32-bit build breakage I see with the current next
>> branch.
>>
>
> Also, Marcelo sees autotest breakage, so it's also broken on 64-bit
> somehow.
>
Obviously, the 64-bit case is considered stable now and 32 bit remained
untested (not included in autotest?). So here is the build fix:
---------->
KVM: x86: Fix 32-bit build breakage due to typo
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
arch/x86/kvm/x86.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index bb9a24a..097ad3a 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3322,7 +3322,7 @@ EXPORT_SYMBOL_GPL(emulator_write_emulated);
# define CMPXCHG64(ptr, old, new) CMPXCHG_TYPE(u64, ptr, old, new)
#else
# define CMPXCHG64(ptr, old, new) \
- (cmpxchg64((u64 *)(ptr), *(u64 *)(old), *(u *)(new)) == *(u64 *)(old))
+ (cmpxchg64((u64 *)(ptr), *(u64 *)(old), *(u64 *)(new)) == *(u64 *)(old))
#endif
static int emulator_cmpxchg_emulated(unsigned long addr,
--
1.6.0.2
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]
next prev parent reply other threads:[~2010-03-20 9:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-15 11:59 [PATCH 0/5] Fix some mmu/emulator atomicity issues (v2) Avi Kivity
2010-03-15 11:59 ` [PATCH 1/5] KVM: MMU: Consolidate two guest pte reads in kvm_mmu_pte_write() Avi Kivity
2010-03-15 11:59 ` [PATCH 2/5] KVM: Make locked operations truly atomic Avi Kivity
2010-03-17 7:45 ` Jan Kiszka
2010-03-17 8:05 ` Avi Kivity
2010-03-20 9:14 ` Jan Kiszka [this message]
2010-03-21 14:34 ` [PATCH] KVM: x86: Fix 32-bit build breakage due to typo Avi Kivity
2010-03-15 11:59 ` [PATCH 3/5] KVM: Don't follow an atomic operation by a non-atomic one Avi Kivity
2010-03-15 11:59 ` [PATCH 4/5] KVM: MMU: Do not instantiate nontrapping spte on unsync page Avi Kivity
2010-03-15 11:59 ` [PATCH 5/5] KVM: MMU: Reinstate pte prefetch on invlpg Avi Kivity
2010-03-16 16:36 ` [PATCH 0/5] Fix some mmu/emulator atomicity issues (v2) Marcelo Tosatti
2010-03-16 18:22 ` Alexander Graf
2010-03-16 19:33 ` Marcelo Tosatti
2010-03-17 3:58 ` Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BA491E5.4090500@web.de \
--to=jan.kiszka@web.de \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox