Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp13515pxy; Tue, 4 May 2021 17:21:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrtwu7b86RMnbY/zJn4VfsOvOft0CtNt7lEMgJNpXLlzt3hVFtG7VGIPDXG8wXgXAxVreE X-Received: by 2002:a17:902:104:b029:ec:9fa6:c08 with SMTP id 4-20020a1709020104b02900ec9fa60c08mr29121748plb.10.1620174067965; Tue, 04 May 2021 17:21:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620174067; cv=none; d=google.com; s=arc-20160816; b=n9NivZYYY3QeE8JNQ3xmw/dOlPGdB48MBrO9dsBzDeHqJ9+Gxn9LQeYlSuIcLaTxwU GAKP4ngilg7Wx0pF6MgeSu7dipNQxxQOmnC1Ata6NEElwJ1x0XWxppoXlNUO9Dp3AXpK sh+9aV4d+VRI1DfAsYT0GORdKw+SftWMHHsFtgykD6Y1WIywnjBjjxTqwabFFYI428CL kG0QXPGCHk8iF/5soxh5kZ+aXmCQXtA2c6+tPZnP0ZhrZglUhFApUh7MpWLyhOzwGDyM Rf9q6V4sqiXGdPrSBUrOgZ5WH7HkPAeUQdLEbH+Y9PA3hVMtvc+gEPfOawUmsH6R8ZS5 t55Q== 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=mfpzdmwVw8Fu8OiTw9MqRdmwIyqVsi2gaYUI9OYvwW4=; b=0DXCy+Kvz8occb7g6Iioq7/FuefYQDM/gG42bdnZHjjBMDkg4NLIPJ3JeY5SyvzSiW 0Ch3gIpDuqzCLjJFyLm+Ov4okc2H/J8dnFs3eg8sxr1GeXDOLuii0TLYkhxT369EL2W5 x8OA3ewnVK85VnvukzVbfLiB9J+H2Gk6LoDLiDvbDcTS5rvMobvv48K5ruAVsIy72s/X q8pVCm9FtN74BvLnQl+IjJmexgNqHLZ2VZsCa2+tlX9zMpvN88uHx4Q6pHn9UfH/XsjY DjESr6LzAAGuI4rxC4OMbvYe6kha2G5Ru/mtYi98wbi2Xf1K4VISYXTgoE9Qn3EkOyOH 4Hwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=G+uHX1x0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b23si5340583pgw.523.2021.05.04.17.20.54; Tue, 04 May 2021 17:21:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=G+uHX1x0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231145AbhEEAOB (ORCPT + 99 others); Tue, 4 May 2021 20:14:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229586AbhEEAOA (ORCPT ); Tue, 4 May 2021 20:14:00 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B899C061574 for ; Tue, 4 May 2021 17:13:05 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id m11so658034pfc.11 for ; Tue, 04 May 2021 17:13:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=mfpzdmwVw8Fu8OiTw9MqRdmwIyqVsi2gaYUI9OYvwW4=; b=G+uHX1x0P+n4lyX0+pqw4LNOwzexQCbLGOM9frm33kz66Vn11x0QAJttUvxQ26k9cR OdWt60KwLGz+I+eiSgA360T+UNOlywi7GocCedS0+PhIf99bnfX3HJUefdd7mG3AeQXk n+W3smbT5Y5GQ9E16Ag3Qwmz0VX4D0NXF89oQnBG3BwiyKb8/vBw/wENfbR5BE+69+0r s0LLAdYzBNAyh3PwTw7J4N848ucTzd9bxtQicP9FsP8GEMzQHoC1eAkkDjwNE26xr+W1 JDq3JBEZqUIYMArk0CkqUAxmGzl0F3bp7FF0bRlio59PnsYxLY7nZF9givRLeJI+OTFI 53IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=mfpzdmwVw8Fu8OiTw9MqRdmwIyqVsi2gaYUI9OYvwW4=; b=uf9nuaqdMdDGnSy7I5OEtGmEQrR3B52uZkGDduuBlkqFcgMjzX4n/4kP+XxvhVkboV nFkyfWFzLaz9TwWN8etfFTmDpOH1c418tjX8d3wul/rb16FFGfEl+1jrG0df+g3rREdG eVM6cd/ofyQXO/1AiYnZuc9Rm8uFzj8rzteDI/uXcEG1cqK3PpYJO1W+J+X8CMcPI3cr 8UEts4GRGv+tWOEVvPU+Hg7PCOY3A+8y7eSzp04SDkPwCrLIp1Rsg6owg1jNnVU1sM+1 z0148QFkS0OTIfwASpAwyeNJzBPoJUP9bGs/TE01EgWFjNlqg6GL1eZtmHBLcMcqzPYf MlMw== X-Gm-Message-State: AOAM530jS8uA6Ex/LrhNOp8EXX7orrQhjet6na4G2YvdVttFzwShXolz /Ur8twG2wfweJYOXIfJ6aEaBUMqR2P8ogQ== X-Received: by 2002:a63:ea0b:: with SMTP id c11mr25501127pgi.120.1620173584654; Tue, 04 May 2021 17:13:04 -0700 (PDT) Received: from devbox.home ([50.39.96.2]) by smtp.gmail.com with ESMTPSA id v123sm13305399pfb.80.2021.05.04.17.12.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 May 2021 17:12:53 -0700 (PDT) Date: Tue, 4 May 2021 17:11:54 -0700 From: Pawan Gupta To: Ramakrishna Saripalli Cc: linux-kernel@vger.kernel.org, x86@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, Jonathan Corbet , bsd@redhat.com Subject: Re: [PATCH v4 1/1] x86/cpufeatures: Implement Predictive Store Forwarding control. Message-ID: <20210505001154.rmibherzitm2yaga@devbox.home> References: <20210430131733.192414-1-rsaripal@amd.com> <20210430131733.192414-2-rsaripal@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline In-Reply-To: <20210430131733.192414-2-rsaripal@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30.04.2021 08:17, Ramakrishna Saripalli wrote: >--- a/arch/x86/kernel/cpu/amd.c >+++ b/arch/x86/kernel/cpu/amd.c >@@ -1170,3 +1170,26 @@ void set_dr_addr_mask(unsigned long mask, int dr) > break; > } > } >+ >+static int __init psf_cmdline(char *str) >+{ >+ u64 tmp = 0; >+ >+ if (!boot_cpu_has(X86_FEATURE_PSFD)) >+ return 0; >+ >+ if (!str) >+ return -EINVAL; >+ >+ if (!strcmp(str, "off")) { >+ set_cpu_cap(&boot_cpu_data, X86_FEATURE_MSR_SPEC_CTRL); >+ rdmsrl(MSR_IA32_SPEC_CTRL, tmp); >+ tmp |= SPEC_CTRL_PSFD; >+ x86_spec_ctrl_base |= tmp; I don't think there is a need to update x86_spec_ctrl_base here. check_bugs() already reads the MSR_IA32_SPEC_CTRL and updates x86_spec_ctrl_base. >+ wrmsrl(MSR_IA32_SPEC_CTRL, x86_spec_ctrl_base); >+ } >+ >+ return 0; >+} >+ >+early_param("predict_store_fwd", psf_cmdline); >diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c >index d41b70fe4918..536136e0daa3 100644 >--- a/arch/x86/kernel/cpu/bugs.c >+++ b/arch/x86/kernel/cpu/bugs.c >@@ -78,6 +78,8 @@ EXPORT_SYMBOL_GPL(mds_idle_clear); > > void __init check_bugs(void) > { >+ u64 tmp = 0; >+ > identify_boot_cpu(); > > /* >@@ -97,7 +99,9 @@ void __init check_bugs(void) > * init code as it is not enumerated and depends on the family. > */ > if (boot_cpu_has(X86_FEATURE_MSR_SPEC_CTRL)) >- rdmsrl(MSR_IA32_SPEC_CTRL, x86_spec_ctrl_base); >+ rdmsrl(MSR_IA32_SPEC_CTRL, tmp); >+ >+ x86_spec_ctrl_base |= tmp; This change also doesn't seem to be necessary, psf_cmdline() updates the MSR( i.e. sets PSFD). Here read from the MSR will still update x86_spec_ctrl_base to the correct value. Am I missing something? Thanks, Pawan