Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5253912imm; Tue, 21 Aug 2018 08:40:01 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyi2MpM1KGo7AylKOoPU/IEiZAA/M2sQyczpSBOe7pIsIqx7iHCmIxjN9eLUrPMkKNG2W30 X-Received: by 2002:a17:902:864b:: with SMTP id y11-v6mr51232257plt.335.1534866001553; Tue, 21 Aug 2018 08:40:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534866001; cv=none; d=google.com; s=arc-20160816; b=DLUmtA8J6AoaTmUAfuCRRjokc3TA4R33JmvUAazG/WMAhMP7Y5ypyEqjLiBroCyOJ+ f/rttUhG9EdDqReGkiUCYHB0veVO0QC95zytZqcS1WRtVzOorw3/Vo8kbHw7poonmHaX NFddPSs8x7LnsVjus4hx8FKTkw9lQTyvtBxgioqMcbrMJKpFtSO3Ll554bHyc6Yfj6CM Rd0/bTeKttZZ6oWvgnBgtKzEKTzPL2fSmPLJ9mivrkGth+9MiWTfDHFicf17HCGT6O2W 8e13UEOmARE2IFPisNh/6vwVxezjiu19rcJ+yigny8ubIAzJbSj9751mrx9MfOdd0vgz yYJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=68azaJL5tU/8T7+aZ7eiU5BfrLUPyw1feWVgVdxmLlQ=; b=LqX8ZsbAHrozRbbY5HOs1KCD44moX6hLVNHTTtNNWrEa5UK2HvrEFZbFrs3iEsj1kk dBlc+/UIxrOdEtXCEZ9eTWk1HXw1kk3sWXA9o4+3jkY2iOojNioWK3AMu166C+unkMDk nr/JxA5lC2GuSZoJIzA5SCoQGP3Vqp5kuDfQJTPCI7x6aLkeKckjVpX6abCJVGSFB8wp 7OT44FDVhcPIX6xMX1av9UOL4FqI9f0bVQWXyN2GAknVN7+El/W+z0myMqM0JWWqJtAl zUn1aKrTARg9dgB+WJEfCMZ2/q+VdQ6SnfhdFyrzYPgjk/j5Y0iInizfA0VpxaNn8GMe 0iHw== 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 a1-v6si13295786pli.472.2018.08.21.08.39.35; Tue, 21 Aug 2018 08:40:01 -0700 (PDT) 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 S1728017AbeHUS6n (ORCPT + 99 others); Tue, 21 Aug 2018 14:58:43 -0400 Received: from mx2.suse.de ([195.135.220.15]:50306 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727956AbeHUS6n (ORCPT ); Tue, 21 Aug 2018 14:58:43 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 33161AD73; Tue, 21 Aug 2018 15:38:04 +0000 (UTC) From: Juergen Gross To: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, x86@kernel.org Cc: boris.ostrovsky@oracle.com, hpa@zytor.com, tglx@linutronix.de, mingo@redhat.com, Juergen Gross Subject: [PATCH v2 1/2] x86/xen: don't write ptes directly in 32-bit PV guests Date: Tue, 21 Aug 2018 17:37:54 +0200 Message-Id: <20180821153755.30462-2-jgross@suse.com> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20180821153755.30462-1-jgross@suse.com> References: <20180821153755.30462-1-jgross@suse.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In some cases 32-bit PAE PV guests still write PTEs directly instead of using hypercalls. This is especially bad when clearing a PTE as this is done via 32-bit writes which will produce intermediate L1TF attackable PTEs. Change the code to use hypercalls instead. Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich --- arch/x86/xen/mmu_pv.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c index 9e7012858420..9396b4d17064 100644 --- a/arch/x86/xen/mmu_pv.c +++ b/arch/x86/xen/mmu_pv.c @@ -434,14 +434,13 @@ static void xen_set_pud(pud_t *ptr, pud_t val) static void xen_set_pte_atomic(pte_t *ptep, pte_t pte) { trace_xen_mmu_set_pte_atomic(ptep, pte); - set_64bit((u64 *)ptep, native_pte_val(pte)); + __xen_set_pte(ptep, pte); } static void xen_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) { trace_xen_mmu_pte_clear(mm, addr, ptep); - if (!xen_batched_set_pte(ptep, native_make_pte(0))) - native_pte_clear(mm, addr, ptep); + __xen_set_pte(ptep, native_make_pte(0)); } static void xen_pmd_clear(pmd_t *pmdp) @@ -1569,7 +1568,7 @@ static void __init xen_set_pte_init(pte_t *ptep, pte_t pte) pte = __pte_ma(((pte_val_ma(*ptep) & _PAGE_RW) | ~_PAGE_RW) & pte_val_ma(pte)); #endif - native_set_pte(ptep, pte); + __xen_set_pte(ptep, pte); } /* Early in boot, while setting up the initial pagetable, assume -- 2.13.7