Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6526222rwb; Mon, 5 Dec 2022 13:44:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf6VOI27ykuw5f2mmNJLTF8aSxM5cvUMqYIDuwYOnvc7bbcAwvOFWeP9Fck5pM7wAGyC/UbS X-Received: by 2002:a05:6402:d78:b0:46b:a177:9d84 with SMTP id ec56-20020a0564020d7800b0046ba1779d84mr24683922edb.134.1670276644965; Mon, 05 Dec 2022 13:44:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670276644; cv=none; d=google.com; s=arc-20160816; b=DjkDPFWamHfgLaOwzI8D8bD76lU5QGzQ3pdRozzHAY86Y2nguJCzHY73yTFPZK0bUj STHUrmf/te2WbV2GOI7Ykh87iARgySdFIPi1hdiv2HNe0AQDtdRFaZ1BiUU6oSzv1oAH RWHbvNLq7M2Pi3/BaQ8g/Y6RGTOES8/YwSqlxtZDkET8iA3DR4bo5AIv8yQPVHN0QKFx 4WRTYkrKR4M5XWW3pNS7KQ7DeHasltmdV9dB2kVKFP+/0ov+jRKS8aLOinPSdy/J2LUe YU4+RPokM/3D3EKYh2YfP6jGdeGLyDFh+8xTeEyyAXcxccDoCtfIN+hP7fbo1ZgUF5yz wrgA== 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=9BS9+Fk77r2sqEaU7XwhOF5T7uvKSgLeTZbiEXUGcMo=; b=zNdZ/coXH2JPFIvcLm/+nXSLEvAh8eYCG4wMc16ysS2SgWyL6MN9Yrm+O6BegxLC92 GAfoB+tb6Ct7+URZhL7axqX5jZafDY39dkf0P0Tx1NNe5VlrE9RnjiGjok3ensZis5+B J1feyiBY0cA1qFm/u7Gp/bXsHFq82p/GpicSRVtktcE5iO97JFm8JQ4MTnyotF/gFl9/ UwJ0DGZCrwG0cmu+HHhUTCg5HvfwdnKbtcOUfbAAnE56dPRY9eo6mJMaNjCxYfN4Qkny 0dgdV9eFc3dQW+ZgxEAe2w1ZdM9t6Qd3OmYgU7zTenmYwpUybcmuhOkh5nTIUyvXOiy0 9xWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="Ujio/I//"; 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 qb27-20020a1709077e9b00b007809c50fd78si13574199ejc.262.2022.12.05.13.43.44; Mon, 05 Dec 2022 13:44:04 -0800 (PST) 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="Ujio/I//"; 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 S232341AbiLEVMs (ORCPT + 80 others); Mon, 5 Dec 2022 16:12:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232179AbiLEVMp (ORCPT ); Mon, 5 Dec 2022 16:12:45 -0500 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F43EDED2 for ; Mon, 5 Dec 2022 13:12:44 -0800 (PST) Received: by mail-pg1-x52e.google.com with SMTP id 6so11589058pgm.6 for ; Mon, 05 Dec 2022 13:12:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=9BS9+Fk77r2sqEaU7XwhOF5T7uvKSgLeTZbiEXUGcMo=; b=Ujio/I//LxFB/K3sVL9gmNsGJ2wTNbSjKjPUCByX11FEgdEzOgOqiXg/gRqfeGF7s+ BRBVYIHZsjiCW+mopZZqJtOFx8R72OQ+lxd1rMhvvBVaCHky62qMT42W7ann/KH4QVEi 7RDo5VhBRC8pzm08UnWL1v8bR/cRgCAMAHzAeJOZ77ZAJGj5jTiVT2fPdcmD7+sDDe5A MCK85CoektbMIOfXCT03EXGqxDh77jznAXbuGFlYRgsEHGnbyTN0uldNNg+81eLCMpdy 485zxEh+YV7agkZEO9zh/Zlc6/uD1mmvMxm2NZPEwpELq6RwwxuABQO2pRIN5lh3pL9X 0pWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=9BS9+Fk77r2sqEaU7XwhOF5T7uvKSgLeTZbiEXUGcMo=; b=nDi5HjkhK+ncicvgap50+TyMpgxZWjGkopfdYkwD3BGZAHurVp8+72LJJrYFN9Im0W S4zwYaPQ3qiNh689a3uFzxo4C0m8qUhWU6faJTlc1RFOl5GHRI+oRPTD042UijBTUh/y KtmZcD0COhNA9qDrSSIhpaKdoMROH/1hvIg9kXpCWIhxhIOiiM5WI/cgvUn97GqJeeQJ k0ptnG/U1p1H3Mej1s7ixXUp8Uq4vIxpo35pKOC7KT1EwBPTYfnyzAS2s6wKeokZt3Xd exMxj1UsjnH30ly1208qWcU9s/WRi6HFiVvoYKJY8ecWyzxG+O+yQzjIR5Er67ZOfYGm z7HQ== X-Gm-Message-State: ANoB5pkhqUnWZXI6A5Ck80meCNJWmDZW/CnRfohEi3UZvVTZjMDOGo+n zhlic7uq8STRvS8DhEaTYtAo7Q== X-Received: by 2002:aa7:91d6:0:b0:574:c543:f804 with SMTP id z22-20020aa791d6000000b00574c543f804mr49454104pfa.51.1670274763510; Mon, 05 Dec 2022 13:12:43 -0800 (PST) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id nn6-20020a17090b38c600b00219f8eb271fsm131413pjb.5.2022.12.05.13.12.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Dec 2022 13:12:43 -0800 (PST) Date: Mon, 5 Dec 2022 21:12:39 +0000 From: Sean Christopherson To: Isaku Yamahata Cc: Paolo Bonzini , Marc Zyngier , Huacai Chen , Aleksandar Markovic , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Matthew Rosato , Eric Farman , Vitaly Kuznetsov , David Woodhouse , Paul Durrant , James Morse , Alexandru Elisei , Suzuki K Poulose , Oliver Upton , Atish Patra , David Hildenbrand , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, Yuan Yao , Cornelia Huck , Isaku Yamahata , Philippe =?iso-8859-1?Q?Mathieu-Daud=E9?= , Fabiano Rosas , Michael Ellerman , Kai Huang , Chao Gao , Thomas Gleixner Subject: Re: [PATCH v2 31/50] KVM: x86: Do CPU compatibility checks in x86 code Message-ID: References: <20221130230934.1014142-1-seanjc@google.com> <20221130230934.1014142-32-seanjc@google.com> <20221205205246.GA3630770@ls.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221205205246.GA3630770@ls.amr.corp.intel.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, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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, Dec 05, 2022, Isaku Yamahata wrote: > On Wed, Nov 30, 2022 at 11:09:15PM +0000, > > index 66f16458aa97..3571bc968cf8 100644 > > --- a/arch/x86/kvm/x86.c > > +++ b/arch/x86/kvm/x86.c > > @@ -9277,10 +9277,36 @@ static inline void kvm_ops_update(struct kvm_x86_init_ops *ops) > > kvm_pmu_ops_update(ops->pmu_ops); > > } > > > > +struct kvm_cpu_compat_check { > > + struct kvm_x86_init_ops *ops; > > + int *ret; > > minor nitpick: just int ret. I don't see the necessity of the pointer. > Anyway overall it looks good to me. ... > > @@ -9360,6 +9386,14 @@ static int __kvm_x86_vendor_init(struct kvm_x86_init_ops *ops) > > if (r != 0) > > goto out_mmu_exit; > > > > + c.ret = &r; > > + c.ops = ops; > > + for_each_online_cpu(cpu) { > > + smp_call_function_single(cpu, kvm_x86_check_cpu_compat, &c, 1); > > + if (r < 0) > > Here it can be "c.ret < 0". No, because the below goto leads to "return r", i.e. "c.ret" needs to be propagated to "r". That's why the code does the admittedly funky "int *ret" thing. FWIW, this gets cleanup in the end. "struct kvm_cpu_compat_check" goes away and "&r" is passed directly to kvm_x86_check_cpu_compat. > > + goto out_hardware_unsetup;