Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3299827iob; Mon, 16 May 2022 18:36:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzW4581TlMGNAA+RHeof1L5i7aFGPolYe1r9m8JQTxqCpI2t5SoiNF4f5b+PjavQtFy4hJf X-Received: by 2002:a17:90a:a410:b0:1dc:d03b:5623 with SMTP id y16-20020a17090aa41000b001dcd03b5623mr22711785pjp.95.1652751404345; Mon, 16 May 2022 18:36:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652751404; cv=none; d=google.com; s=arc-20160816; b=sxMfaKZb9c1CwqOrdvfSC79DhvkWM2PdPfwt6dr79MNy6MWr538jmq82I1WtP32mpV pjFuqRY5qEF1pqC/VTfMdZzCZwB3uyaGGILAAouOcZJcOeo7Pjngn1AyyykgBvgYriGi 7jk5j7hCvMA94XxDx2eNcxzz/XsoMiwCvpKEO3uBn7WoIQenpwq204DtjxNdBsm59XnU iFUExsardjZ6bpGEV28uXlXLmXPz7MQd9CnEiKH74dTpK6JjdrHbbv6wbEYJ0sz0N29Q JTAAnhKxLAn02fQC54VsklKvlkyc/fik1GrrZLd6NDNJZR4S3/THrFGJJRvz0CGxfb92 H/3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=18f9yUH1/w73tmifgqC4XWy7DHTtV6nZ9pn9JLOs8G4=; b=HNxSwwSakhBSvoTsy7IMdxYw/JFu4Tpz3TAqoaabz2vgafDPg+8KlpVmBRbIg4YFPH 44Qn9EZy4NA/FDKeUPF/G5LTHbZ0mtDnWAa9kngybuS1dFiYrF5xaLBtYvEoZpJGxIqr 8nra8Q5Sbcmbd8FkevaClClZt17gYFNE1jO64MN2HwD+hTXe7YRzIYMygXH1QRfYQk8R W6C0dB5wNQv/rQO1j2ybM/AknZAlH63vCgqLnoq7IPlvBT544sVdajm502hlK9MIrzsP SGhQyVt9ZWUskkfB8q0LPxOOSqI9P4P5qkPHJH769fN6sW6TCVPcXHzA0a3IGZ6KRhRl P5yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=BMoeDTwm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t11-20020a056a0021cb00b004fa3a8dffa1si16031586pfj.88.2022.05.16.18.36.32; Mon, 16 May 2022 18:36:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=BMoeDTwm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244828AbiEPPOq (ORCPT + 99 others); Mon, 16 May 2022 11:14:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235121AbiEPPOo (ORCPT ); Mon, 16 May 2022 11:14:44 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59FE83BA4F for ; Mon, 16 May 2022 08:14:43 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id d22so14708230plr.9 for ; Mon, 16 May 2022 08:14:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=18f9yUH1/w73tmifgqC4XWy7DHTtV6nZ9pn9JLOs8G4=; b=BMoeDTwmiLVu4Yp7Hb0ZS2ktRN19j8if9lN2p7YpJuwfvZMETAPUAdeU+YJo8AMPlg MCmCHbU/CKD+LiJ4Pjfxlbhvfk/1AnBjSBNX8oqKjnw2ya2zf2vVny5Md7+vJt+qJmrb BUOkJ4YyEHH5sBZGFEGxEMDm4W4V9BG0n98a8oqKwLXaVlrIeEkMuA2dKL21KgzGM9Az 4SxA5msjI+ifRYKYSZrH/gue3IMkfqclFB9pBj2pz1khU112i/89GzVXLgdUDbOb4R1b 46QRgkkcE/HkoH2njsKRysihh3Y2ZFmA78C3nh8fkKStwO/MW/69ph4fWii92pqlgvno b92A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=18f9yUH1/w73tmifgqC4XWy7DHTtV6nZ9pn9JLOs8G4=; b=6Dm5RWKQNRsV0L+Lv6s7NNCJU4/8jf+ffo1b9exdtinu80RUmIePWE4CJ53yIO9vae iKxIk82dlFkxY3srJlLFFF/cixQRAe6ZQlUDSsSFmULtrwb8bC64AiRzXboJahwRcfut wGL0K9DngI4uCRBJiUk67tIKvEmgujb1Qr5UulmDCnCIdUAuRdMpMOXysznW419qurb0 2VAJXZko1TB+svBzyTeyFTIyRno0eXGDvM9qfrCDtBYtLM4lw/Dge7gx0wXd8ABQ0vHs qq0349CPjnsYLDgfVfkSCN8RpgedHAAjzRogreWbFy3vv3cz2zb61k5h8kQ5xGxGtgIY ewEg== X-Gm-Message-State: AOAM5305HsNQaIOzHNhqMMQ42CbOJAhMRLc8zDpoC1hD4uzfWjtBL/bm 8ygdhmN4haAvmipKUkp8lvEZtw== X-Received: by 2002:a17:903:288:b0:15f:4cc6:3195 with SMTP id j8-20020a170903028800b0015f4cc63195mr17620427plr.45.1652714082615; Mon, 16 May 2022 08:14:42 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id b12-20020a17090a5a0c00b001ded49491basm198821pjd.2.2022.05.16.08.14.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 08:14:41 -0700 (PDT) Date: Mon, 16 May 2022 15:14:36 +0000 From: Sean Christopherson To: Maxim Levitsky Cc: Uros Bizjak , Peter Zijlstra , X86 ML , LKML , kvm@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Will Deacon , Boqun Feng , Mark Rutland , "Paul E. McKenney" , Marco Elver Subject: Re: [PATCH] locking/atomic/x86: Introduce try_cmpxchg64 Message-ID: References: <20220510154217.5216-1-ubizjak@gmail.com> <20220510165506.GP76023@worktop.programming.kicks-ass.net> <20220511075409.GX76023@worktop.programming.kicks-ass.net> <9ed2fc294bf2c21b41b22605ff8039bb71903712.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9ed2fc294bf2c21b41b22605ff8039bb71903712.camel@redhat.com> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 16, 2022, Maxim Levitsky wrote: > On Mon, 2022-05-16 at 14:08 +0000, Sean Christopherson wrote: > > On Mon, May 16, 2022, Maxim Levitsky wrote: > > > On Wed, 2022-05-11 at 21:54 +0200, Uros Bizjak wrote: > > > > On Wed, May 11, 2022 at 6:04 PM Sean Christopherson wrote: > > > > > On Wed, May 11, 2022, Uros Bizjak wrote: > > > > > > On Wed, May 11, 2022 at 9:54 AM Peter Zijlstra wrote: > > > > > > > Still, does 32bit actually support that stuff? > > > > > > > > > > > > Unfortunately, it does: > > > > > > > > > > > > kvm-intel-y += vmx/vmx.o vmx/vmenter.o vmx/pmu_intel.o vmx/vmcs12.o \ > > > > > > vmx/evmcs.o vmx/nested.o vmx/posted_intr.o > > > > > > > > > > > > And when existing cmpxchg64 is substituted with cmpxchg, the > > > > > > compilation dies for 32bits with: > > > > > > > > > > ... > > > > > > > > > > > > Anyway, your patch looks about right, but I find it *really* hard to > > > > > > > care about 32bit code these days. > > > > > > > > > > > > Thanks, this is also my sentiment, but I hope the patch will enable > > > > > > better code and perhaps ease similar situation I have had elsewhere. > > > > > > > > > > IMO, if we merge this it should be solely on the benefits to 64-bit code. Yes, > > > > > KVM still supports 32-bit kernels, but I'm fairly certain the only people that > > > > > run 32-bit KVM are KVM developers. 32-bit KVM has been completely broken for > > > > > multiple releases at least once, maybe twice, and no one ever complained. > > > > > > > > Yes, the idea was to improve cmpxchg64 with the implementation of > > > > try_cmpxchg64 for 64bit targets. However, the issue with 32bit targets > > > > stood in the way, so the effort with 32-bit implementation was mainly > > > > to unblock progression for 64-bit targets. > > > > > > Would that allow tdp mmu to work on 32 bit? > > > > From a purely technical perspective, there's nothing that prevents enabling the > > TDP MMU on 32-bit kernels. The TDP MMU is 64-bit only to simplify the implementation > > and to reduce the maintenance and validation costs. > > I understand exactly that, so the question, will this patch help make the tdp > mmu work transparently on 32 bit kernels? I heard that 64 bit cmpxchg was > one of the main reasons that it is 64 bit only. I don't think it moves the needled much, e.g. non-atomic 64-bit accesses are still problematic, and we'd have to update the TDP MMU to deal with PAE paging (thanks NPT). All those problems are solvable, it's purely a matter of the ongoing costs to solve them. > I am asking because there was some talk to eliminate the direct mode from the > legacy non tdp mmu, which would simplify its code by a lot, but then it will > make 32 bit kernel fail back to shadowing mmu. Simplify which code? Between the nonpaging code and direct shadow pages in indirect MMUs, the vast majority of the "direct" support in the legacy MMU needs to be kept even if TDP support is dropped. And the really nasty stuff, e.g. PAE roots, would need to be carried over to the TDP MMU.