From patchwork Wed Sep 11 15:26:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 11141387 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B946114ED for ; Wed, 11 Sep 2019 15:28:25 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9F1692084D for ; Wed, 11 Sep 2019 15:28:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9F1692084D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i84W9-0002sK-GN; Wed, 11 Sep 2019 15:26:49 +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 1i84W7-0002rZ-N4 for xen-devel@lists.xenproject.org; Wed, 11 Sep 2019 15:26:47 +0000 X-Inumbo-ID: 908f2716-d4a8-11e9-83d9-12813bfff9fa Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 908f2716-d4a8-11e9-83d9-12813bfff9fa; Wed, 11 Sep 2019 15:26:47 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 61145AF3B; Wed, 11 Sep 2019 15:26:46 +0000 (UTC) From: Jan Beulich To: "xen-devel@lists.xenproject.org" References: Message-ID: Date: Wed, 11 Sep 2019 17:26:46 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Subject: [Xen-devel] [PATCH 9/9] x86: PCID is unused when !PV 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: George Dunlap , Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This allows in particular some streamlining of the TLB flushing code paths. Signed-off-by: Jan Beulich --- a/xen/arch/x86/flushtlb.c +++ b/xen/arch/x86/flushtlb.c @@ -24,6 +24,11 @@ #define WRAP_MASK (0x000003FFU) #endif +#ifndef CONFIG_PV +# undef X86_CR4_PCIDE +# define X86_CR4_PCIDE 0 +#endif + u32 tlbflush_clock = 1U; DEFINE_PER_CPU(u32, tlbflush_time); --- a/xen/include/asm-x86/processor.h +++ b/xen/include/asm-x86/processor.h @@ -289,7 +289,11 @@ static inline unsigned long cr3_pa(unsig static inline unsigned int cr3_pcid(unsigned long cr3) { +#ifdef CONFIG_PV return cr3 & X86_CR3_PCID_MASK; +#else + return 0; +#endif } static inline unsigned long read_cr4(void) @@ -301,8 +305,12 @@ static inline void write_cr4(unsigned lo { struct cpu_info *info = get_cpu_info(); +#ifdef CONFIG_PV /* No global pages in case of PCIDs enabled! */ ASSERT(!(val & X86_CR4_PGE) || !(val & X86_CR4_PCIDE)); +#else + ASSERT(!(val & X86_CR4_PCIDE)); +#endif /* * On hardware supporting FSGSBASE, the value in %cr4 is the kernel's --- a/xen/include/asm-x86/pv/domain.h +++ b/xen/include/asm-x86/pv/domain.h @@ -50,8 +50,13 @@ */ static inline unsigned long get_pcid_bits(const struct vcpu *v, bool is_xpti) { +#ifdef CONFIG_PV return X86_CR3_NOFLUSH | (is_xpti ? PCID_PV_XPTI : 0) | ((v->arch.flags & TF_kernel_mode) ? PCID_PV_PRIV : PCID_PV_USER); +#else + ASSERT_UNREACHABLE(); + return 0; +#endif } #ifdef CONFIG_PV