Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2631045rdb; Fri, 22 Sep 2023 04:34:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH7RtkK/9VtnY8ielclqVmatQJhc607x0GHmNufxkda/p0R09FIzjKIZVo6fA7YjQDiHcSh X-Received: by 2002:a05:6359:ba7:b0:143:81bd:c0ec with SMTP id gf39-20020a0563590ba700b0014381bdc0ecmr3762479rwb.6.1695382497031; Fri, 22 Sep 2023 04:34:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695382496; cv=none; d=google.com; s=arc-20160816; b=awqxQ5sU47ygVxSYU996J5IDMMrXgX7qjuHfyFH8UbYTa2JRlAH1DfZjiJR4nuGXvX ff5UogfNUviDDVB3rbINgs0QhuODStHnzPAtFkaEtGJT436XlrhCjWiHboVcyh5IJD+y m9L6OwYNabI5LWMu23gWcIJeemkA+SUZC7NylMzvq7dRXtboutqT6J2bre8L0y98KrKX X8H2IVs+Sp02YisBT2M/aFYViUDxzZyFj5osmmRyf7WugVDNhjbbccPnuumfKzdhLSXc ma22ysnz7WAey3pd/iZbf/XYAAqTjOQZxGPYAEveIlkUkbqv0HWHOQeyNMMLBeSf/yFv 7bPw== 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:sender:dkim-signature; bh=P/Yn3YU3xUZyWUWNBFaFLjez0LaX2XHNQTW5YI4iTAM=; fh=HBVnCmC93nffF0fp8vAigKisdOvJ/e7XN/ra7tmjwjI=; b=iOkOa79eYTD/T+g1fna9PU/2R201xEQt4tr+HcBMTjzSz/Ju3e+YCQ7TiBb4fQO3uZ lnHgiYQeA7MjcpQVUFaeuVD8qY/MidO/Y+/1iojmxUh47OwYVGZjC/5aSuTJ3wpp2JzF dfzDyTGVQvAb95998awayGYiDeNcDJ1d639pzQuQ0SVD87sXkr/dYPHMJHpNHaABmfAa gE+9gFpSfCxElET6SxIB/hUDWCJBteFsux1Sk7BvlrOgP6Dup880mGuYm4sSFteOJLyt 8WPJ3u0WQNUdSyPa03Yh7+1HzZ26Tzx3eeisLOGCTjCUUviitZq9FRXCszcnYCWzQKss UtbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=R3rYn8By; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id a22-20020a63cd56000000b00577516d9a1esi3561491pgj.172.2023.09.22.04.34.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 04:34:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=R3rYn8By; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id D845481E3E10; Fri, 22 Sep 2023 03:26:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229810AbjIVK0V (ORCPT + 99 others); Fri, 22 Sep 2023 06:26:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbjIVK0U (ORCPT ); Fri, 22 Sep 2023 06:26:20 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D153BA9; Fri, 22 Sep 2023 03:26:13 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-405361bb93bso15057605e9.3; Fri, 22 Sep 2023 03:26:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695378372; x=1695983172; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=P/Yn3YU3xUZyWUWNBFaFLjez0LaX2XHNQTW5YI4iTAM=; b=R3rYn8BymfNcpPuFJ9/lOJxvrpsDZLp9iYrgv1vol8Og8wAbjgZ5ust5cTs/iiSsV3 PpdSR/YRo++/PynlSRdtlQjmbwCinQ6PUSZxs0F2sPUhfaEcYkiMCHjMrC5ipmQg3AZa mcv3uPiAdMmFLeEQEINDQ+t9BALlRe5+4HhvlTEPFMwClCxKnNKB53C0rvmvkLanAhzM xl7kyFitNrDnGcz6h31XquOxYiK30TDl/pwMyzjuy2MXPKXi8BaRIlWrsDMA35LE/gox dlce0jumMN/iUISdFn13wIhL4g5l/sAgxAkhMwv/6tOCryCJ+JJKKv+myAaCc3taSO7L gkFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695378372; x=1695983172; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P/Yn3YU3xUZyWUWNBFaFLjez0LaX2XHNQTW5YI4iTAM=; b=Vuf2TdRn5BpHWxANH0MUhy7kq8cUNGshX/UrUzxnCy6TifzkALdNAaNd3+IU0RVlYl v/+U/LrDyCpMFjGrFUHBXh9GLw15eliOhikGzS8U1bjyCAU7Gk/81sMkd9jTy+RPEeG0 K4HjQ/bEzgFEuzNRSeyGN+1kRysEXe9QI2S5VlKJEk4Uj/Ny0o3JHgxhvC38ErNk8GuK IE7/6gJX4c+6MSo3W8/I6gVbOScm8myP841I+wsDA6aQhcdM9P8HmaT476qoyxnweA3g 4WYH2WZEVAZqXbMZQxCHiIov0iSgTPs3Zi0KS4ZPcJXilkXzSv2S1gcMmah7+5Pwdeg0 cBPA== X-Gm-Message-State: AOJu0Yw9pDKKf+Y+FIglwh0LkQ02zFqB592ZoRfQAJRLgrvco3aIyDp+ dVzAxQQMuj2yxHbjaeKXZ5aXkzZtMCQ= X-Received: by 2002:a05:600c:1da0:b0:405:3e92:76db with SMTP id p32-20020a05600c1da000b004053e9276dbmr1127667wms.5.1695378371800; Fri, 22 Sep 2023 03:26:11 -0700 (PDT) Received: from gmail.com (1F2EF49C.nat.pool.telekom.hu. [31.46.244.156]) by smtp.gmail.com with ESMTPSA id 7-20020a05600c028700b00402c0a8a084sm7094849wmk.17.2023.09.22.03.26.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 03:26:11 -0700 (PDT) Sender: Ingo Molnar Date: Fri, 22 Sep 2023 12:26:09 +0200 From: Ingo Molnar To: linux-kernel@vger.kernel.org Cc: linux-tip-commits@vger.kernel.org, Paolo Bonzini , "Borislav Petkov (AMD)" , x86@kernel.org Subject: Re: [tip: x86/cpu] x86/cpu: Clear SVM feature if disabled by BIOS Message-ID: References: <20230921114940.957141-1-pbonzini@redhat.com> <169537583818.27769.18320521458994415527.tip-bot2@tip-bot2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <169537583818.27769.18320521458994415527.tip-bot2@tip-bot2> X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 22 Sep 2023 03:26:23 -0700 (PDT) * tip-bot2 for Paolo Bonzini wrote: > --- a/arch/x86/kernel/cpu/amd.c > +++ b/arch/x86/kernel/cpu/amd.c > @@ -1031,6 +1031,8 @@ static void zenbleed_check(struct cpuinfo_x86 *c) > > static void init_amd(struct cpuinfo_x86 *c) > { > + u64 vm_cr; > + > early_init_amd(c); > > /* > @@ -1082,6 +1084,14 @@ static void init_amd(struct cpuinfo_x86 *c) > > init_amd_cacheinfo(c); > > + if (cpu_has(c, X86_FEATURE_SVM)) { > + rdmsrl(MSR_VM_CR, vm_cr); > + if (vm_cr & SVM_VM_CR_SVM_DIS_MASK) { > + pr_notice_once("SVM disabled (by BIOS) in MSR_VM_CR\n"); > + clear_cpu_cap(c, X86_FEATURE_SVM); > + } > + } > + > if (!cpu_has(c, X86_FEATURE_LFENCE_RDTSC) && cpu_has(c, X86_FEATURE_XMM2)) { > /* > * Use LFENCE for execution serialization. On families which > diff --git a/arch/x86/kernel/cpu/hygon.c b/arch/x86/kernel/cpu/hygon.c > index defdc59..16f3463 100644 > --- a/arch/x86/kernel/cpu/hygon.c > +++ b/arch/x86/kernel/cpu/hygon.c > @@ -290,6 +290,8 @@ static void early_init_hygon(struct cpuinfo_x86 *c) > > static void init_hygon(struct cpuinfo_x86 *c) > { > + u64 vm_cr; > + > early_init_hygon(c); > > /* > @@ -320,6 +322,14 @@ static void init_hygon(struct cpuinfo_x86 *c) > > init_hygon_cacheinfo(c); > > + if (cpu_has(c, X86_FEATURE_SVM)) { > + rdmsrl(MSR_VM_CR, vm_cr); > + if (vm_cr & SVM_VM_CR_SVM_DIS_MASK) { > + pr_notice_once("SVM disabled (by BIOS) in MSR_VM_CR\n"); > + clear_cpu_cap(c, X86_FEATURE_SVM); > + } > + } > + 1) It's a bit sad that we are duplicating identical code. 2) We are doing it in other cases as well: for example nearby_node() is duplicated between arch/x86/kernel/cpu/amd.c and arch/x86/kernel/cpu/hygon.c too. 3) BTW., while look at this code I noticed that the 'Author' copyright tag in arch/x86/kernel/cpu/hygon.c seems to be inaccurate: // SPDX-License-Identifier: GPL-2.0+ /* * Hygon Processor Support for Linux * * Copyright (C) 2018 Chengdu Haiguang IC Design Co., Ltd. * * Author: Pu Wen */ ... as for example the nearby_node() was clearly copied & derived from arch/x86/kernel/cpu/amd.c, which does not appear to be accurately reflected in this copyright notice? Thanks, Ingo