From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68AA3C433F5 for ; Thu, 27 Jan 2022 09:56:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 09D8F6B0072; Thu, 27 Jan 2022 04:56:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 04D8F6B0075; Thu, 27 Jan 2022 04:56:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA6A46B0078; Thu, 27 Jan 2022 04:56:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0128.hostedemail.com [216.40.44.128]) by kanga.kvack.org (Postfix) with ESMTP id DCB9C6B0072 for ; Thu, 27 Jan 2022 04:56:26 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 9963F92ECE for ; Thu, 27 Jan 2022 09:56:26 +0000 (UTC) X-FDA: 79075611972.22.E5E8C1B Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf04.hostedemail.com (Postfix) with ESMTP id F17D440005 for ; Thu, 27 Jan 2022 09:56:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=vXgIaQHv1WwPHTBX3+DS0LsBoq4oci9EBPzt7CvHDrk=; b=Q7RpGLD+CLAuxSeoUa+m+yscqR PXROARvnTVuQl4eCsx0sm104eBUw6cjrSWVM/mgh8V7zPnn3r4FR2lNnAWkGx1bcFywjSxidg3eAC 6qsf/72PQtVQzaABPK1fNhwzaDC3lcn1QmZ1TzCkL/jAtzFtTyL97n7BmyoFY6e66V6nqMwmHrjPm m4nYp5H+4JHa9otDcQCKogSoIGhK9jP1vUor2qsbcVDmMsDqNWXaltH7rBy0yn0gJWfGUTH79tlSK 5LIr5SsbqOnzLsCQOm/sCLTmS53vjQJg6yrjYx0QVXj2Xi/Zu/P1VVKlHGp8HJjFjpGZ/e0e+vGc2 Dbvixmrw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nD1Ve-00483l-9t; Thu, 27 Jan 2022 09:56:06 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 1E901300268; Thu, 27 Jan 2022 10:56:05 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 114542B383F52; Thu, 27 Jan 2022 10:56:05 +0100 (CET) Date: Thu, 27 Jan 2022 10:56:05 +0100 From: Peter Zijlstra To: Sean Christopherson Cc: mingo@redhat.com, tglx@linutronix.de, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-api@vger.kernel.org, x86@kernel.org, pjt@google.com, posk@google.com, avagin@google.com, jannh@google.com, tdelisle@uwaterloo.ca, mark.rutland@arm.com, posk@posk.io Subject: Re: [RFC][PATCH v2 4/5] x86/uaccess: Implement unsafe_try_cmpxchg_user() Message-ID: References: <20220120155517.066795336@infradead.org> <20220120160822.852009966@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Stat-Signature: dhkhtexbtobzoz55u175gfu8z55u7693 X-Rspam-User: nil Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=Q7RpGLD+; spf=none (imf04.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org; dmarc=none X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: F17D440005 X-HE-Tag: 1643277385-682534 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000013, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Jan 27, 2022 at 06:36:19AM +0000, Sean Christopherson wrote: > On Thu, Jan 27, 2022, Sean Christopherson wrote: > > Doh, I should have specified that KVM needs 8-byte CMPXCHG on 32-bit kernels due > > to using it to atomically update guest PAE PTEs and LTR descriptors (yay). > > > > Also, KVM's use case isn't a tight loop, how gross would it be to add a slightly > > less unsafe version that does __uaccess_begin_nospec()? KVM pre-checks the address > > way ahead of time, so the access_ok() check can be omitted. Alternatively, KVM > > could add its own macro, but that seems a little silly. E.g. somethign like this, > > though I don't think this is correct > > *sigh* > > Finally realized I forgot to add back the page offset after converting from guest > page frame to host virtual address. Anyways, this is what I ended up with, will > test more tomorrow. Looks about right :-) (famous last words etc..)