Received: by 10.223.164.202 with SMTP id h10csp3552342wrb; Tue, 28 Nov 2017 13:12:24 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ90z6zlk/H9pzv4tRYFuO/dJffQK8JBcQ/3OyxB9fPRIZQuuNYz6GsbzVo9SZfAgK4RKyG X-Received: by 10.84.178.131 with SMTP id z3mr484726plb.165.1511903544146; Tue, 28 Nov 2017 13:12:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511903544; cv=none; d=google.com; s=arc-20160816; b=rgGqtto1LPnhBVuSTaiCDbWmaGugoMQanNYgxe7x5PTHFPHOi3nvybQLIBkiyhh4oi v5YeKJA/sNtor2UnEeish4auyCZZnmD3oeS+2g0WTh8nUwYV7/JGqua8TG7v89jk36Uf w3Ee+NrkK0xbjc1dnksuI/DFF8n1Sjm3IYzutbbWt/IvOvEnZECOnH4ns0RLA8hE4Nbu jSDs63DAvTzbHCR8R0WT2ueBpD+iNp0tm3UzqwkZUqcDh2HryGWNWw6bmkPucvN8AJ+D ndjInztxZpCMgLPuvBj5T3h80BjImo2SUMCD0Ii92FIPUGzTl8T0bAFVMhnHeUDKT1tP 87/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:cc:to:references:subject:from:arc-authentication-results; bh=WifEDRIDWx3QSg88MpSklHHlEv/JUNjypJeVjg7S55w=; b=U4QGPxP0qIHN7YYAr/uVPVz+6hrE4DMStFYyjjJAMKlVnoLBtsAj4k3L0WWGAkfkxs 5FIJbJNYuLFVTsSgyrtPIa+uTDiT/62xB64hloLAE2xtVc4cDQAivVmSCfFOACffL2q1 aMdk2LNOvOnCGzW9EwpDHW0uWMP/zuk/GG8XiUTq2Cz9KJVZwB9KgiRMTOKl3nQS1oUA CqY9LewqxOH/TQmvo12U7Usub1iry29h2dhfTNmTp3mcolJTXG2dowF5+La7D28KPM1j X1be6CL1Mz4fWthijeDcj/pTPyww9bhYwwRqgL3qC6tNL+8HkOxfLKZmjeEMDwk9uaOf cFGQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d3si41146pgq.709.2017.11.28.13.12.13; Tue, 28 Nov 2017 13:12:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752314AbdK1VLf (ORCPT + 70 others); Tue, 28 Nov 2017 16:11:35 -0500 Received: from mail.medvecky.net ([85.118.132.146]:38502 "EHLO mail.medvecky.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751239AbdK1VLe (ORCPT ); Tue, 28 Nov 2017 16:11:34 -0500 X-Greylist: delayed 597 seconds by postgrey-1.27 at vger.kernel.org; Tue, 28 Nov 2017 16:11:33 EST Received: from localhost (localhost [127.0.0.1]) by mail.medvecky.net (Postfix) with ESMTP id D31155E2002; Tue, 28 Nov 2017 22:00:38 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at medvecky.net X-Spam-Flag: NO X-Spam-Score: -2.9 X-Spam-Level: X-Spam-Status: No, score=-2.9 tagged_above=-999 required=3.8 tests=[ALL_TRUSTED=-1, BAYES_00=-1.9] autolearn=ham Received: from mail.medvecky.net ([127.0.0.1]) by localhost (slovakia.medvecky.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id G6WGBgck9ENN; Tue, 28 Nov 2017 22:00:11 +0100 (CET) Received: from [192.168.88.62] (56.32.broadband3.iol.cz [85.70.32.56]) by mail.medvecky.net (Postfix) with ESMTPSA id C17D55E2001; Tue, 28 Nov 2017 22:00:10 +0100 (CET) From: Rudolf Marek Subject: [PATCH] x86: make X86_BUG_FXSAVE_LEAK detectable in CPUID on AMD References: <558a0f66-002b-7365-9988-9877b95a2c31@assembler.cz> <20171118180538.e7b5l4r2j5l5esjd@pd.tnic> <4813068b-f669-5239-f3a4-6e57af77be4c@assembler.cz> <20171119103001.ncjck5wbzaqyqewo@pd.tnic> To: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org Cc: andy Lutomirski , Borislav Petkov , lkml Message-ID: Date: Tue, 28 Nov 2017 22:01:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171119103001.ncjck5wbzaqyqewo@pd.tnic> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The latest AMD AMD64 Architecture Programmer's Manual adds a CPUID feature XSaveErPtr (CPUID_Fn80000008_EBX[2]). If this feature is set, the FXSAVE, XSAVE, FXSAVEOPT, XSAVEC, XSAVES / FXRSTOR, XRSTOR, XRSTORS always save/restore error pointers, thus making the X86_BUG_FXSAVE_LEAK workaround obsolete on such CPUs. Signed-Off-By: Rudolf Marek Reviewed-and-tested-by: Borislav Petkov --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/amd.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index c0b0e9e..800104c 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -266,6 +266,7 @@ /* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */ #define X86_FEATURE_CLZERO (13*32+ 0) /* CLZERO instruction */ #define X86_FEATURE_IRPERF (13*32+ 1) /* Instructions Retired Count */ +#define X86_FEATURE_XSAVEERPTR (13*32+ 2) /* Always save/restore FP error pointers */ /* Thermal and Power Management Leaf, CPUID level 0x00000006 (EAX), word 14 */ #define X86_FEATURE_DTHERM (14*32+ 0) /* Digital Thermal Sensor */ diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index d58184b..bcb75dc 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -804,8 +804,11 @@ static void init_amd(struct cpuinfo_x86 *c) case 0x17: init_amd_zn(c); break; } - /* Enable workaround for FXSAVE leak */ - if (c->x86 >= 6) + /* + * Enable workaround for FXSAVE leak on CPUs + * without a XSaveErPtr feature + */ + if ((c->x86 >= 6) && (!cpu_has(c, X86_FEATURE_XSAVEERPTR))) set_cpu_bug(c, X86_BUG_FXSAVE_LEAK); cpu_detect_cache_sizes(c); -- 2.7.4 From 1586545185162859503@xxx Tue Dec 12 02:56:34 +0000 2017 X-GM-THRID: 1586545185162859503 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread