From patchwork Fri Jul 19 10:29:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 11049979 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9D9A913BD for ; Fri, 19 Jul 2019 10:31:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89F74288B7 for ; Fri, 19 Jul 2019 10:31:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A1EF288BE; Fri, 19 Jul 2019 10:31:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0434C288B7 for ; Fri, 19 Jul 2019 10:31:32 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hoQ9S-0004Fk-QO; Fri, 19 Jul 2019 10:30:10 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hoQ9R-0004FX-Dg for xen-devel@lists.xenproject.org; Fri, 19 Jul 2019 10:30:09 +0000 X-Inumbo-ID: 2b82be16-aa10-11e9-8caa-938f29f2802e Received: from m4a0039g.houston.softwaregrp.com (unknown [15.124.2.85]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 2b82be16-aa10-11e9-8caa-938f29f2802e; Fri, 19 Jul 2019 10:30:06 +0000 (UTC) Received: FROM m4a0039g.houston.softwaregrp.com (15.120.17.147) BY m4a0039g.houston.softwaregrp.com WITH ESMTP; Fri, 19 Jul 2019 10:30:02 +0000 Received: from M4W0334.microfocus.com (2002:f78:1192::f78:1192) by M4W0335.microfocus.com (2002:f78:1193::f78:1193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Fri, 19 Jul 2019 10:29:13 +0000 Received: from NAM04-BN3-obe.outbound.protection.outlook.com (15.124.8.12) by M4W0334.microfocus.com (15.120.17.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10 via Frontend Transport; Fri, 19 Jul 2019 10:29:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D7W7I6UYjJYeq4PA+Sva3B9MJD3OpkLz05j1CpkG9MKAPhCon4mARmi7WnogcrOEE1fdArz+jOEJL4iGF530zONaUKJMu7fFMuwvoDMg73DzNsWeevSAdmpnjm287vqd7Vp8wyiFqYWl3sGXo1VyRQH/51eZomzoKKgSUKP1jV/PHJCgDP/f19XGCGDiKpdZskqLBDDq3mXGCRPnfMeC+dr6eg3W3WkVea7gdA/2jBeyX3h/2wUfrWacR5L4Yxkg9YIfCBHtDqNgvNbz5i3WbwtwO8lzGldk2ucTK3YhYj1tRwgWP6UENcnTUmaJ5MM1JN4HDLziXALuO8O94ckJuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qvVnFIBxtG1VqNAilCVCJY2BYlSAiKIw3lPug2FFKw4=; b=XRGp0tuDmrw/e8pUTrlUkPL7NVG3Z8gV7Xz89M/7mMlHI5prAGoxNSvjnGYur5pR/Q8dJkho1X+pLxOiA+YUB5QitsMAMk3HNld5HLed3PZWv3s+72kSAt+OHHbSRwep1uhi9TrMSh7Rfs9MVePeJ8eKHbzzVvV3pkCG/TNo5jw2ingoARqHjxICH0MhiSoSRahqaj7ApA4fQStXAWMF9Xp51zHX8H/HMz+HyCOI7FRP7NnuKNWAePSXA+oe7J5i5mDJjZfKIuAXPoWzU6RWI9kSPSDweimRDZDXtS1wK1pOsNBOViSe9w+U2rNQ06x8/dBHdFztLK9bA7/f2Z2Pzw== ARC-Authentication-Results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=suse.com;dmarc=pass action=none header.from=suse.com;dkim=pass header.d=suse.com;arc=none Received: from DM6PR18MB3401.namprd18.prod.outlook.com (10.255.174.218) by DM6PR18MB2540.namprd18.prod.outlook.com (20.179.105.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2094.12; Fri, 19 Jul 2019 10:29:11 +0000 Received: from DM6PR18MB3401.namprd18.prod.outlook.com ([fe80::1fe:35f6:faf3:78c7]) by DM6PR18MB3401.namprd18.prod.outlook.com ([fe80::1fe:35f6:faf3:78c7%7]) with mapi id 15.20.2073.012; Fri, 19 Jul 2019 10:29:11 +0000 From: Jan Beulich To: "xen-devel@lists.xenproject.org" Thread-Topic: [PATCH v2 1/2] x86/cpu/intel: Clear cache self-snoop capability in CPUs with known errata Thread-Index: AQHVPhzObMH32PKqfka5dBK6AxG1/g== Date: Fri, 19 Jul 2019 10:29:11 +0000 Message-ID: References: <0ccb27d1-6612-d915-a898-8423ac3afdd0@suse.com> In-Reply-To: <0ccb27d1-6612-d915-a898-8423ac3afdd0@suse.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: LO2P265CA0318.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a4::18) To DM6PR18MB3401.namprd18.prod.outlook.com (2603:10b6:5:1cc::26) authentication-results: spf=none (sender IP is ) smtp.mailfrom=JBeulich@suse.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [87.234.252.170] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3cd9dc7f-2a39-4b19-3330-08d70c33f0b4 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:DM6PR18MB2540; x-ms-traffictypediagnostic: DM6PR18MB2540: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2803; x-forefront-prvs: 01039C93E4 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(39860400002)(136003)(376002)(346002)(396003)(366004)(199004)(189003)(66066001)(446003)(11346002)(3846002)(6116002)(6436002)(36756003)(26005)(53936002)(5640700003)(2616005)(476003)(102836004)(186003)(6486002)(478600001)(14454004)(2351001)(25786009)(256004)(486006)(6506007)(71200400001)(7736002)(6916009)(71190400001)(2501003)(316002)(4326008)(99286004)(8676002)(305945005)(86362001)(31696002)(54906003)(31686004)(5660300002)(2906002)(66556008)(76176011)(52116002)(6512007)(386003)(80792005)(66946007)(81156014)(68736007)(8936002)(81166006)(66446008)(64756008)(66476007); DIR:OUT; SFP:1102; SCL:1; SRVR:DM6PR18MB2540; H:DM6PR18MB3401.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: suse.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: o1il4NumIbrL7IaNZ+CxYBCvIE+ZedMPik1kpU3oXGnBc2nnzIYO5+Av2ptgMWkb5YbZmKVoeEj5Pp6bT55VIG/RWUf8ypoWhf9upsNbg6lFkv6hhFlwOgq5J+AiWmJP5FjKzG/2FKrFutLy68ybpRPwuMOwU+u1/zqKA53X/K44mYwQURsI4vwf8r9pAHyZLBjxj9yj8UIqP7+bI9+o9ZJHHECTW380z01CEr406xZt/YCyJ4Mmwzzo/xotjFaTw21je09HpRp4XIANJYiILQk8zP/L5PH7y+KdrHE5opdLVqgvAWIC5Jj2YXD95Eg1lYhIVXgpPEQwMZb+9gC7yhi4F8S17PtHKWIlajHPMmbirXhsRjZm/Su4Vpqi8TZ4hh8hG+bdf8HnsDcBaAxKLO60TsCceM1VlnRUgAk56Ew= Content-ID: <4CC21AF714A82747BDEB6CD3E73ECC72@namprd18.prod.outlook.com> MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 3cd9dc7f-2a39-4b19-3330-08d70c33f0b4 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jul 2019 10:29:11.8250 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 856b813c-16e5-49a5-85ec-6f081e13b527 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: JBeulich@suse.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR18MB2540 X-OriginatorOrg: suse.com Subject: [Xen-devel] [PATCH v2 1/2] x86/cpu/intel: Clear cache self-snoop capability in CPUs with known errata X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Ricardo Neri Processors which have self-snooping capability can handle conflicting memory type across CPUs by snooping its own cache. However, there exists CPU models in which having conflicting memory types still leads to unpredictable behavior, machine check errors, or hangs. Clear this feature on affected CPUs to prevent its use. Suggested-by: Alan Cox Signed-off-by: Ricardo Neri [Linux commit 1e03bff3600101bd9158d005e4313132e55bdec8] Strip Yonah - as per ark.intel.com it doesn't look to be 64-bit capable. Call the new function on the boot CPU only. Don't clear the CPU feature flag itself, as it is exposed to guests (who could otherwise observe it disappear after migration). Requested-by: Andrew Cooper Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper --- v2: Introduce and use XEN_SELFSNOOP. --- NB: The function name isn't fully appropriate anymore, but I'd prefer to keep Linux'es name to allow matching the two changes. --- a/xen/arch/x86/cpu/intel.c +++ b/xen/arch/x86/cpu/intel.c @@ -15,6 +15,36 @@ #include "cpu.h" /* + * Processors which have self-snooping capability can handle conflicting + * memory type across CPUs by snooping its own cache. However, there exists + * CPU models in which having conflicting memory types still leads to + * unpredictable behavior, machine check errors, or hangs. Clear this + * feature to prevent its use on machines with known erratas. + */ +static void __init check_memory_type_self_snoop_errata(void) +{ + if (!boot_cpu_has(X86_FEATURE_SS)) + return; + + switch (boot_cpu_data.x86_model) { + case 0x0f: /* Merom */ + case 0x16: /* Merom L */ + case 0x17: /* Penryn */ + case 0x1d: /* Dunnington */ + case 0x1e: /* Nehalem */ + case 0x1f: /* Auburndale / Havendale */ + case 0x1a: /* Nehalem EP */ + case 0x2e: /* Nehalem EX */ + case 0x25: /* Westmere */ + case 0x2c: /* Westmere EP */ + case 0x2a: /* SandyBridge */ + return; + } + + setup_force_cpu_cap(X86_FEATURE_XEN_SELFSNOOP); +} + +/* * Set caps in expected_levelling_cap, probe a specific masking MSR, and set * caps in levelling_caps if it is found, or clobber the MSR index if missing. * If preset, reads the default value into msr_val. @@ -256,8 +286,11 @@ static void early_init_intel(struct cpui (boot_cpu_data.x86_mask == 3 || boot_cpu_data.x86_mask == 4)) paddr_bits = 36; - if (c == &boot_cpu_data) + if (c == &boot_cpu_data) { + check_memory_type_self_snoop_errata(); + intel_init_levelling(); + } ctxt_switch_levelling(NULL); } --- a/xen/include/asm-x86/cpufeatures.h +++ b/xen/include/asm-x86/cpufeatures.h @@ -30,6 +30,7 @@ XEN_CPUFEATURE(SC_MSR_PV, (FSCAPIN XEN_CPUFEATURE(SC_MSR_HVM, (FSCAPINTS+0)*32+17) /* MSR_SPEC_CTRL used by Xen for HVM */ XEN_CPUFEATURE(SC_RSB_PV, (FSCAPINTS+0)*32+18) /* RSB overwrite needed for PV */ XEN_CPUFEATURE(SC_RSB_HVM, (FSCAPINTS+0)*32+19) /* RSB overwrite needed for HVM */ +XEN_CPUFEATURE(XEN_SELFSNOOP, (FSCAPINTS+0)*32+20) /* SELFSNOOP gets used by Xen itself */ XEN_CPUFEATURE(SC_MSR_IDLE, (FSCAPINTS+0)*32+21) /* (SC_MSR_PV || SC_MSR_HVM) && default_xen_spec_ctrl */ XEN_CPUFEATURE(XEN_LBR, (FSCAPINTS+0)*32+22) /* Xen uses MSR_DEBUGCTL.LBR */ XEN_CPUFEATURE(SC_VERW_PV, (FSCAPINTS+0)*32+23) /* VERW used by Xen for PV */