From patchwork Thu Nov 17 09:19:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suleiman Souhlal X-Patchwork-Id: 13046387 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 23E1CC43219 for ; Thu, 17 Nov 2022 09:22:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239769AbiKQJWP (ORCPT ); Thu, 17 Nov 2022 04:22:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239957AbiKQJVu (ORCPT ); Thu, 17 Nov 2022 04:21:50 -0500 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AC7A6D48B for ; Thu, 17 Nov 2022 01:21:45 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-391bd92f931so4548287b3.22 for ; Thu, 17 Nov 2022 01:21:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=pZu1L6aeNZHO+yUsZiZqCDyduTaPbwNJn2PXrr8Ee2g=; b=EKyOSgVSRsZSS3rxYo9VEj9jrPmeIBUeeducxdzJPD1QdTr6BVNaM42Bb0b1gXW7Sc O0and3SGj2h9vKSohF/6NFaICsiRowwiq+dLZrnWBJ8wxoJPMp9AcpAjHihomOkGLjat lWUd4qthe90FCRZjC4TBfuELNMbbFuRi1M+vFPGJwlqc/HlcZXCkrHkdVYgQYSxQyCx0 nZQ6CzGH8OBf8qDiaHeS0tmqGca92ppqi3hcmEIUX9HMnr4W9lGOoRBchp+duCAswmbN BafJJwpoNHdcgLX3U4PjKk4xrqjKPzKoX7CDvtu1XPJwCoUCzVQLT1RgMVi3IKU55Ez/ s8ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pZu1L6aeNZHO+yUsZiZqCDyduTaPbwNJn2PXrr8Ee2g=; b=RMT9fqVEEK676HLaNSG5n6SjPJDiu8NEQIY1EXnLGgyS79VM1v+4NnM0OasrL+7x3i N8sgL/Eo/bOIH4yGeYnqntLGUc6U/5C6aND6FJv9mpntqjUqTgx8YYX09v4oVMLYTWLc 6cgpHcDGZvoUI99IS0I8n738xZF7Rs1pRQyox39cRN7hcz84KQDqF3ImOcGM2iv/sbea wtMKyh6jQCD+8M+LAStlWlJouAtzh2bx85U/tPDN3cdvBMTs/TsQcCpsqfVPcVIUV2gW gY5eBLPU0JnK+nk/eGhwsDHYM0xhwsuJD89VER+i84u2Zi9tVjigrWAWUfWvu2bUlD0e yItQ== X-Gm-Message-State: ANoB5pm9E82ZFB57xeP+6myN4ea4JtkqM1osYmZ6UBqo5RMVE+ricpoA s8ACOvmOR23q9U6hC+oR6mucnIulDS1L/w== X-Google-Smtp-Source: AA0mqf57MkjOGcj0/5BQEReTka6kyBlsCiDfHCcKTL+Ma4e6pqERrzWn3R2nCPbtW1nTqBYu+Fe15Kg3U0PDGQ== X-Received: from suleiman1.tok.corp.google.com ([2401:fa00:8f:203:416e:f3c7:7f1d:6e]) (user=suleiman job=sendgmr) by 2002:a25:ef4d:0:b0:6dd:ebd8:6204 with SMTP id w13-20020a25ef4d000000b006ddebd86204mr1337937ybm.471.1668676904345; Thu, 17 Nov 2022 01:21:44 -0800 (PST) Date: Thu, 17 Nov 2022 18:19:40 +0900 In-Reply-To: <20221117091952.1940850-1-suleiman@google.com> Message-Id: <20221117091952.1940850-23-suleiman@google.com> Mime-Version: 1.0 References: <20221117091952.1940850-1-suleiman@google.com> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog Subject: [PATCH 4.19 22/34] x86/speculation: Fix SPEC_CTRL write on SMT state change From: Suleiman Souhlal To: stable@vger.kernel.org Cc: x86@kernel.org, kvm@vger.kernel.org, bp@alien8.de, pbonzini@redhat.com, peterz@infradead.org, jpoimboe@kernel.org, cascardo@canonical.com, surajjs@amazon.com, ssouhlal@FreeBSD.org, suleiman@google.com Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Josh Poimboeuf commit 56aa4d221f1ee2c3a49b45b800778ec6e0ab73c5 upstream. If the SMT state changes, SSBD might get accidentally disabled. Fix that. Signed-off-by: Josh Poimboeuf Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Signed-off-by: Thadeu Lima de Souza Cascardo Signed-off-by: Greg Kroah-Hartman Signed-off-by: Suleiman Souhlal --- arch/x86/kernel/cpu/bugs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 0734f35d1af1..e720dee4d30b 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -1335,7 +1335,8 @@ static void __init spectre_v2_select_mitigation(void) static void update_stibp_msr(void * __unused) { - write_spec_ctrl_current(x86_spec_ctrl_base, true); + u64 val = spec_ctrl_current() | (x86_spec_ctrl_base & SPEC_CTRL_STIBP); + write_spec_ctrl_current(val, true); } /* Update x86_spec_ctrl_base in case SMT state changed. */