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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2F9EC6FA82 for ; Tue, 27 Sep 2022 00:41:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229740AbiI0AlM (ORCPT ); Mon, 26 Sep 2022 20:41:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229932AbiI0Ak6 (ORCPT ); Mon, 26 Sep 2022 20:40:58 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82E3E3A494; Mon, 26 Sep 2022 17:40:57 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id p14so5190850pjd.3; Mon, 26 Sep 2022 17:40:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=8xobog+QYukwZVnSxEr7+7WqxBnwEIa9rhAbHRvLuc0=; b=FTCMFRmQQyCukqL2hxWYCxKVenu9ShL50Yamg226yHwQtpyuDdPtGQPzXO/k1rYqWq kpc2VrBXq8xqNic4OqxT4fAyTdTUyb81ViwXcqIWHthuzOgp7A33k5MTIpiJ/mMQpPhA 6eMBZccoaglWqBm+WdqkktjAdyy6SGAn4tCKEmQA3ZjpPfCL0FILKRgWRkoSRGCE4gC+ 7ldMIkIMU4dHHAJ7fORc8bubpbNKM9jjI4OFwNwoWsYZJUI7Zt9UDrxcCoeuS6xfmi1M tSOqrp6yZVxQEtcdRZdoPwXBp01Y9N3cE3zt0LabBjPooc0427RdfI08Clap3VSZQnxP xOTQ== 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; bh=8xobog+QYukwZVnSxEr7+7WqxBnwEIa9rhAbHRvLuc0=; b=EKI2WSLXLJN1x/nzFgpdI80fPXEa45a3b/NZSvCaAAck0wDJjiuWtoOlDTtc7YqhgW gclrHCqawCZgC6QLHYPT/cHc6Uznsibh+XQNeGA86oqD6cuIakkn1YpMcjnnqotFr/Iw jHDQEI3thtS5eJ3qiDKPH6XPhh7avALOIu38MXs0QnhmbPtiH8PJLpc+N7FNejh/zdc+ zByUWJHjwdxVweZLNEgQ9NSGXVBiS9aVbpicL9NexKSQe9DWI1X8APr8Ynbn18y97IUT YXC3uRum65/ahJOyMkp+c5fiiyB4Hm4A+yzq3gsWZ75P+H2xqAq+iZmYriFjd2LlDpEj e3wA== X-Gm-Message-State: ACrzQf2ooMfY717WIAstsrOlmH0RiXgkbI3gJ3iZ46SryjunTGi+adU/ yDJ4dtg8SwEu2XBPVpAjgZo= X-Google-Smtp-Source: AMsMyM5ncLCON7H69CwN1h2mFJChlFCT/tOjvv+vDzOyTbAYe4LWup3DROUOLB0qK9ZqLDTMs+Q+/w== X-Received: by 2002:a17:902:7e42:b0:178:489:86ac with SMTP id a2-20020a1709027e4200b00178048986acmr24950551pln.68.1664239256857; Mon, 26 Sep 2022 17:40:56 -0700 (PDT) Received: from localhost ([192.55.54.55]) by smtp.gmail.com with ESMTPSA id d14-20020a17090a3b0e00b002009db534d1sm68572pjc.24.2022.09.26.17.40.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 17:40:56 -0700 (PDT) Date: Mon, 26 Sep 2022 17:40:54 -0700 From: Isaku Yamahata To: Michael Ellerman Cc: isaku.yamahata@intel.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Sean Christopherson , Thomas Gleixner , Marc Zyngier , Will Deacon , isaku.yamahata@gmail.com, Kai Huang , Chao Gao , Atish Patra , Shaokun Zhang , Daniel Lezcano , Huang Ying , Huacai Chen , Dave Hansen , Borislav Petkov , linuxppc-dev@lists.ozlabs.org, Fabiano Rosas Subject: Re: [PATCH v5 27/30] RFC: KVM: powerpc: Move processor compatibility check to hardware setup Message-ID: <20220927004054.GA1508394@ls.amr.corp.intel.com> References: <574ca90fdaec0f37c197d9600d47d48a74f324bd.1663869838.git.isaku.yamahata@intel.com> <8735ci1sri.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <8735ci1sri.fsf@mpe.ellerman.id.au> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 23, 2022 at 04:58:41PM +1000, Michael Ellerman wrote: > isaku.yamahata@intel.com writes: > > From: Isaku Yamahata > > > > Move processor compatibility check from kvm_arch_processor_compat() into > ^ > kvm_arch_check_processor_compat() > > > kvm_arch_hardware_setup(). The check does model name comparison with a > > global variable, cur_cpu_spec. There is no point to check it at run time > > on all processors. > > A key detail I had to look up is that both kvm_arch_hardware_setup() and > kvm_arch_check_processor_compat() are called from kvm_init(), one after > the other. But the latter is called on each CPU. > > And because the powerpc implementation of kvm_arch_check_processor_compat() > just checks a global, there's no need to call it on every CPU. > > > kvmppc_core_check_processor_compat() checks the global variable. There are > > five implementation for it as follows. > > There are three implementations not five. Thanks. I'll update the commit message. > > arch/powerpc/include/asm/cputable.h: extern struct cpu_spec *cur_cpu_spec; > > arch/powerpc/kvm/book3s.c: return 0 > > arch/powerpc/kvm/e500.c: strcmp(cur_cpu_spec->cpu_name, "e500v2") > > arch/powerpc/kvm/e500mc.c: strcmp(cur_cpu_spec->cpu_name, "e500mc") > > strcmp(cur_cpu_spec->cpu_name, "e5500") > > strcmp(cur_cpu_spec->cpu_name, "e6500") > > > > Suggested-by: Sean Christopherson > > Signed-off-by: Isaku Yamahata > > Cc: linuxppc-dev@lists.ozlabs.org > > Cc: Fabiano Rosas > > --- > > arch/powerpc/kvm/powerpc.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c > > index 7b56d6ccfdfb..31dc4f231e9d 100644 > > --- a/arch/powerpc/kvm/powerpc.c > > +++ b/arch/powerpc/kvm/powerpc.c > > @@ -444,12 +444,12 @@ int kvm_arch_hardware_enable(void) > > > > int kvm_arch_hardware_setup(void *opaque) > > { > > - return 0; > > + return kvmppc_core_check_processor_compat(); > > } > > > > int kvm_arch_check_processor_compat(void) > > { > > - return kvmppc_core_check_processor_compat(); > > + return 0; > > } > > The actual change seems OK. I gave it a quick test boot and ran some > VMs, everything seems to work as before. > > Acked-by: Michael Ellerman (powerpc) Thanks so much for testing. I'll remove RFC. -- Isaku Yamahata