Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1730390rdg; Sat, 14 Oct 2023 15:08:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHudBStImGvV3F+HkUtua/EayqVZ0ACBggkPaYUr1CysAhOsfqgQWE+ItudOmyKFZvIKIUJ X-Received: by 2002:a05:6358:2810:b0:166:a821:334e with SMTP id k16-20020a056358281000b00166a821334emr5265782rwb.18.1697321309601; Sat, 14 Oct 2023 15:08:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697321309; cv=none; d=google.com; s=arc-20160816; b=k4u+vU6SyGnCaWwoCpIIARtZmflfC7If9T6i2C3z+tpy/x0vpdOndgrt0G6xDkYdgR LmraIjHswlXD6U80dEQNopedLhnfkJiXO09Rr1ZPzeuINFYaCeotSHpU33GaRKB7O1nm aDwrnS7fRqjq0RWw3DRJTXQR+SGudJ/TWOD4n1NPwuiSnYMZLkmEp/edmZYc/CsJJXX4 afwGmitMoB6UpnEnKbgf3hg2sk/EW1kiEmkSewV97kZswfz2621/t3vziQnAxVWmrk76 d3d0SiTA/eCQ6d8vfRNnwqnfi8/OXLC7XWY+dq/OLC51kv1d2t2jAJQ4hEbsllFR1xfE IBow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:sender:dkim-signature; bh=ghDZoWO9ubo5ZD+moVqdmgS7dUweAjCjy7g/qakcfGI=; fh=UANtPEHvdzu+w/ugxNm2NYr4kSF2sDiQ8QW/5S+EVYQ=; b=e8euPupWtEx/JBXgTRmgf3dWi7bJJOPUeOSdnoF3pmBTytqus6xVgC8jAEmyvBVyYy blcxvOicAfPCFNHDEy+rI/sgvvcuLg1S1n0B2AdIjIggm89zpj1+pFGawmVfnz43d5AF 0Qf2E5xQwsMcx8GSJsa1n6YyV8GHsUUTIJxnW+zRTo3e1BSSN5Y8V+JrWLptlTNCKjEq gTh1l7o9IVyf3N5iibEME4H2IAeY7K5fDhNorf3pg82oPsdFEOyj+j11INE1XoOGEiV/ fw1izaN6Gd3pCV3Wq7tSW02L2mr6yadmit3DMlC+dkESq+HUiDltES0UtKQP/J3eX/Tr dPXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=kUaPEhU4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id j2-20020a056a00130200b006906a716917si11118492pfu.398.2023.10.14.15.08.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Oct 2023 15:08:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=kUaPEhU4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 9CDEA8047542; Sat, 14 Oct 2023 15:08:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229867AbjJNWI0 (ORCPT + 99 others); Sat, 14 Oct 2023 18:08:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229555AbjJNWIZ (ORCPT ); Sat, 14 Oct 2023 18:08:25 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0BA1C9 for ; Sat, 14 Oct 2023 15:08:23 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4054496bde3so32870775e9.1 for ; Sat, 14 Oct 2023 15:08:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697321302; x=1697926102; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :sender:from:to:cc:subject:date:message-id:reply-to; bh=ghDZoWO9ubo5ZD+moVqdmgS7dUweAjCjy7g/qakcfGI=; b=kUaPEhU4OZGvmuaJUBM+yhEeQ7Ldm2cSfMA9HIMzN+a0SgokQHVlzUFPjS8ICKhCVI y+QyyP2PS1eWMA4bVhZpqxcU/YU3rmEiHcDl6V1BgCmxUaO6L3/8GRTVjI+ZnqaK3nPK yMOpLzROssUIAlxLEXZa9Nqjsmp1FCG6dksTEsXIWeTUjaQ9kbq/WvfBV4BtONhVFjqr 9iqTpTlQ8VBN+HRMDYMeGHlCLy/tPKWcrXWNWAJ22tfFjulUPJO4cpYVu7wObEiW96iU eKlTB8wrUUIzDBOwdTvs4cnpyPg8kbY1KBHe8tSfu7V5tPG50qxHedToAhKuSvmPfGK7 kJiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697321302; x=1697926102; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ghDZoWO9ubo5ZD+moVqdmgS7dUweAjCjy7g/qakcfGI=; b=QiRoheakOYa2fh4MzIa48n31jrHEFUiQmQ0bPlzwPdATb3niiSqGwbVSIC2F1abFYe XLIqfKqwJdux1IyJJwpA0+oJSx0xf3jJDXNaRzw1wURAcvp104fd428XBJ+ZHGEd4avQ Y3GaZbdxRyr2syoKvioir7VUOR4+01wFFXmvMcBXVdvEnvapgBoiULRWXunovRMR7aMS LCYbJ6+NQi/P9pBMC7kukY4ibVfnNigahiNVa80ya8K9u1XJx7KwJiPJfs7ywVuIk7wz SzpwyEl/Oruc2NlkRP8/+ro4hyX5/5vHU+gFKQ73QiA/MT2PMS7oBlUajPqrweGWGygo ttMA== X-Gm-Message-State: AOJu0Yx0LzVcAMOtByvnERiSv+zOTrYd3WSwUdTfGSLPS83O1FzDchNe pnxjukjFkzMvUfz63J+jiIE= X-Received: by 2002:a5d:570d:0:b0:32d:9e48:c2ef with SMTP id a13-20020a5d570d000000b0032d9e48c2efmr4408631wrv.44.1697321301857; Sat, 14 Oct 2023 15:08:21 -0700 (PDT) Received: from gmail.com (1F2EF7B2.nat.pool.telekom.hu. [31.46.247.178]) by smtp.gmail.com with ESMTPSA id hy1-20020a1709068a6100b0099bc08862b6sm1456293ejc.171.2023.10.14.15.08.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Oct 2023 15:08:20 -0700 (PDT) Sender: Ingo Molnar Date: Sun, 15 Oct 2023 00:08:17 +0200 From: Ingo Molnar To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , Borislav Petkov , Dave Hansen , Peter Zijlstra , Andrew Morton , "H. Peter Anvin" , x86@kernel.org Subject: [GIT PULL] x86 fixes Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_PASS autolearn=no 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sat, 14 Oct 2023 15:08:28 -0700 (PDT) Linus, Please pull the latest x86/urgent git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-urgent-2023-10-15 # HEAD: d35652a5fc9944784f6f50a5c979518ff8dacf61 x86/alternatives: Disable KASAN in apply_alternatives() Fix a false-positive KASAN warning, fix an AMD erratum on Zen4 CPUs, and fix kernel-doc build warnings. Thanks, Ingo ------------------> Borislav Petkov (AMD) (1): x86/cpu: Fix AMD erratum #1485 on Zen4-based CPUs Kirill A. Shutemov (1): x86/alternatives: Disable KASAN in apply_alternatives() Randy Dunlap (1): x86/resctrl: Fix kernel-doc warnings arch/x86/include/asm/msr-index.h | 9 +++++++-- arch/x86/kernel/alternative.c | 13 +++++++++++++ arch/x86/kernel/cpu/amd.c | 8 ++++++++ arch/x86/kernel/cpu/resctrl/monitor.c | 10 +++++----- 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index 1d111350197f..b37abb55e948 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -637,12 +637,17 @@ /* AMD Last Branch Record MSRs */ #define MSR_AMD64_LBR_SELECT 0xc000010e -/* Fam 17h MSRs */ -#define MSR_F17H_IRPERF 0xc00000e9 +/* Zen4 */ +#define MSR_ZEN4_BP_CFG 0xc001102e +#define MSR_ZEN4_BP_CFG_SHARED_BTB_FIX_BIT 5 +/* Zen 2 */ #define MSR_ZEN2_SPECTRAL_CHICKEN 0xc00110e3 #define MSR_ZEN2_SPECTRAL_CHICKEN_BIT BIT_ULL(1) +/* Fam 17h MSRs */ +#define MSR_F17H_IRPERF 0xc00000e9 + /* Fam 16h MSRs */ #define MSR_F16H_L2I_PERF_CTL 0xc0010230 #define MSR_F16H_L2I_PERF_CTR 0xc0010231 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index 517ee01503be..73be3931e4f0 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -403,6 +403,17 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start, u8 insn_buff[MAX_PATCH_LEN]; DPRINTK(ALT, "alt table %px, -> %px", start, end); + + /* + * In the case CONFIG_X86_5LEVEL=y, KASAN_SHADOW_START is defined using + * cpu_feature_enabled(X86_FEATURE_LA57) and is therefore patched here. + * During the process, KASAN becomes confused seeing partial LA57 + * conversion and triggers a false-positive out-of-bound report. + * + * Disable KASAN until the patching is complete. + */ + kasan_disable_current(); + /* * The scan order should be from start to end. A later scanned * alternative code can overwrite previously scanned alternative code. @@ -452,6 +463,8 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start, text_poke_early(instr, insn_buff, insn_buff_sz); } + + kasan_enable_current(); } static inline bool is_jcc32(struct insn *insn) diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index 03ef962a6992..ece2b5b7b0fe 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -80,6 +80,10 @@ static const int amd_div0[] = AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x17, 0x00, 0x0, 0x2f, 0xf), AMD_MODEL_RANGE(0x17, 0x50, 0x0, 0x5f, 0xf)); +static const int amd_erratum_1485[] = + AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x19, 0x10, 0x0, 0x1f, 0xf), + AMD_MODEL_RANGE(0x19, 0x60, 0x0, 0xaf, 0xf)); + static bool cpu_has_amd_erratum(struct cpuinfo_x86 *cpu, const int *erratum) { int osvw_id = *erratum++; @@ -1149,6 +1153,10 @@ static void init_amd(struct cpuinfo_x86 *c) pr_notice_once("AMD Zen1 DIV0 bug detected. Disable SMT for full protection.\n"); setup_force_cpu_bug(X86_BUG_DIV0); } + + if (!cpu_has(c, X86_FEATURE_HYPERVISOR) && + cpu_has_amd_erratum(c, amd_erratum_1485)) + msr_set_bit(MSR_ZEN4_BP_CFG, MSR_ZEN4_BP_CFG_SHARED_BTB_FIX_BIT); } #ifdef CONFIG_X86_32 diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c index ded1fc7cb7cb..f136ac046851 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -30,15 +30,15 @@ struct rmid_entry { struct list_head list; }; -/** - * @rmid_free_lru A least recently used list of free RMIDs +/* + * @rmid_free_lru - A least recently used list of free RMIDs * These RMIDs are guaranteed to have an occupancy less than the * threshold occupancy */ static LIST_HEAD(rmid_free_lru); -/** - * @rmid_limbo_count count of currently unused but (potentially) +/* + * @rmid_limbo_count - count of currently unused but (potentially) * dirty RMIDs. * This counts RMIDs that no one is currently using but that * may have a occupancy value > resctrl_rmid_realloc_threshold. User can @@ -46,7 +46,7 @@ static LIST_HEAD(rmid_free_lru); */ static unsigned int rmid_limbo_count; -/** +/* * @rmid_entry - The entry in the limbo and free lists. */ static struct rmid_entry *rmid_ptrs;