From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>
Cc: Sean Christopherson <seanjc@google.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>,
Joerg Roedel <joro@8bytes.org>,
kvm@vger.kernel.org, llvm@lists.linux.dev,
linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Tadeusz Struk <tadeusz.struk@linaro.org>,
syzbot+6cde2282daa792c49ab8@syzkaller.appspotmail.com
Subject: [PATCH v2 0/5] x86: uaccess CMPXCHG + KVM bug fixes
Date: Wed, 2 Feb 2022 00:49:40 +0000 [thread overview]
Message-ID: <20220202004945.2540433-1-seanjc@google.com> (raw)
Peter, please take a look at unsafe_try_cmpxchg_user() to make sure it
(a) still looks right and (b) works for your use case. I added explicit
casts to play nice with clang and sparse, as well as a __chk_user_ptr()
given the use of __force.
Add uaccess macros for doing CMPXCHG on userspace addresses and use the
macros to fix KVM bugs by replacing flawed code that maps memory into the
kernel address space without proper mmu_notifier protection (or with
broken pfn calculations in one case).
Add yet another Kconfig for guarding asm_volatile_goto() to workaround a
clang-13 bug. I've verified the test passes on gcc versions of arm64,
PPC, RISC-V, and s390x that also pass the CC_HAS_ASM_GOTO_OUTPUT test.
Patches 1-4 are tagged for stable@ as patches 3 and 4 (mostly 3) need a
backportable fix, and doing CMPXCHG on the userspace address is the
simplest fix from a KVM perspective.
v2:
- Explicitly cast with (__force u<size> *) to fix clang+i386
compilation woes and sparse warnings. [kernel test robot]
- Rework i386's CMPXCHG8B to force use of ECX for the error path so that
clang doesn't run out of input/output GPRs...
- Document that gcc also has/had troubles, and note the clang and gcc
versions that (should) work with tied outputs. [Nick]
- Collect tags [Nick, Tadeusz]
v1: https://lore.kernel.org/all/20220201010838.1494405-1-seanjc@google.com
Peter Zijlstra (1):
x86/uaccess: Implement macros for CMPXCHG on user addresses
Sean Christopherson (4):
Kconfig: Add option for asm goto w/ tied outputs to workaround
clang-13 bug
KVM: x86: Use __try_cmpxchg_user() to update guest PTE A/D bits
KVM: x86: Use __try_cmpxchg_user() to emulate atomic accesses
KVM: x86: Bail to userspace if emulation of atomic user access faults
arch/x86/include/asm/uaccess.h | 142 +++++++++++++++++++++++++++++++++
arch/x86/kvm/mmu/paging_tmpl.h | 45 +----------
arch/x86/kvm/x86.c | 35 ++++----
init/Kconfig | 5 ++
4 files changed, 162 insertions(+), 65 deletions(-)
base-commit: 26291c54e111ff6ba87a164d85d4a4e134b7315c
--
2.35.0.rc2.247.g8bbb082509-goog
next reply other threads:[~2022-02-02 0:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-02 0:49 Sean Christopherson [this message]
2022-02-02 0:49 ` [PATCH v2 1/5] Kconfig: Add option for asm goto w/ tied outputs to workaround clang-13 bug Sean Christopherson
2022-02-02 0:49 ` [PATCH v2 2/5] x86/uaccess: Implement macros for CMPXCHG on user addresses Sean Christopherson
2022-02-02 0:49 ` [PATCH v2 3/5] KVM: x86: Use __try_cmpxchg_user() to update guest PTE A/D bits Sean Christopherson
2022-02-02 0:49 ` [PATCH v2 4/5] KVM: x86: Use __try_cmpxchg_user() to emulate atomic accesses Sean Christopherson
2022-05-12 10:14 ` [PATCH] KVM: x86: fix a typo in __try_cmpxchg_user that caused cmpxchg to be not atomic Maxim Levitsky
2022-05-12 12:45 ` Vitaly Kuznetsov
2022-05-12 13:48 ` Sean Christopherson
2022-05-12 15:47 ` Paolo Bonzini
2022-05-12 21:27 ` Sean Christopherson
2022-05-16 13:14 ` Maxim Levitsky
2022-05-16 14:03 ` Sean Christopherson
2022-02-02 0:49 ` [PATCH v2 5/5] KVM: x86: Bail to userspace if emulation of atomic user access faults Sean Christopherson
2022-04-01 7:53 ` [PATCH v2 0/5] x86: uaccess CMPXCHG + KVM bug fixes Paolo Bonzini
2022-04-01 17:07 ` Tadeusz Struk
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=20220202004945.2540433-1-seanjc@google.com \
--to=seanjc@google.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=syzbot+6cde2282daa792c49ab8@syzkaller.appspotmail.com \
--cc=tadeusz.struk@linaro.org \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.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 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.