Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp3847935pxy; Mon, 26 Apr 2021 11:09:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwSgm329jo7Z22Ocbktvyt+3Qv/BkILfAHqC3vFXebtAAyHmKz20KpJvTyri43cOBNpkDI X-Received: by 2002:a17:906:5585:: with SMTP id y5mr19883896ejp.129.1619460564579; Mon, 26 Apr 2021 11:09:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619460564; cv=none; d=google.com; s=arc-20160816; b=Q9iscshu4I9xp57EPcle57jHAbDqRdVcvfs9MitCp2oca5eJj9oU6sgdnlaDQ03Rzj kF6VRmt31YzTg6jPV4f33l1K1dkLd7QGf9YCjeHBuBpfY3+uZV0wLdAqJbVrBhjjhjts w9UAjWBB9bBJdBw2EfrZXxZvaNZeV4QkcJq2XVTdhXfyN8PQ42biTfEP0SyKLevn46hG /fLL1rbJz2psaWGn8/CBzRRsh22Gq5jegrXflXPQ0VGLYGqK2IxLXl93cQua+oQFZS/3 nwFlOf8xkflIA7P/79F+lI6QPAmwa4PnyutYWkGe8R4uVTa9yWF4SCso+syaue+F+Q9Z IBmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=tZn32LaV6SR91TYvV0lmAZzGIO7esN+7N8B8edfzGjA=; b=syunqBiRDw9dL25KDWZU22knkvmFMKv4QLmOx6yuuAlSZak32LX23KEODrMxKYAxyM Ns6yXdFnKLeOuJAkhIlu6y1R0+OquT092A3O5IoXm9RTUATBhaDviLoKPR33wnPeeogz lo050WWcX3NdWrOqNiq/NiemHY52uBcy6OKLT064Ric2vZR6Td6QlFlp/xPD4/KQSiyV hdCz+d6vE3TW4ly9X54qshKAU/p3IcgLFr4gaPTJld5TrEiFRgBJdYSOkgXFKFsm8BfA 3qhiju7ALV3OSiiXtjEvO5el9gJXBtCBbA/aJobwtGHzPzcIfvgQBDBek3rcoPEu6ARz H4yQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v13si536720edl.24.2021.04.26.11.09.00; Mon, 26 Apr 2021 11:09:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234530AbhDZSFp (ORCPT + 99 others); Mon, 26 Apr 2021 14:05:45 -0400 Received: from mga06.intel.com ([134.134.136.31]:20703 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234683AbhDZSEC (ORCPT ); Mon, 26 Apr 2021 14:04:02 -0400 IronPort-SDR: F1FeZ9WRvRjLidrku1gfssP78vgMKt9uy7YPr/2F5PMkqYBCqD8H4QC+hOJRkkcOYLOzmUStRZ 0EgHymGNQvTQ== X-IronPort-AV: E=McAfee;i="6200,9189,9966"; a="257683629" X-IronPort-AV: E=Sophos;i="5.82,252,1613462400"; d="scan'208";a="257683629" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2021 11:02:59 -0700 IronPort-SDR: RrMXPFuZ3IfUD/7TaCzrej7XwkROWc/3jK0mAkJnGnEQcpq7FELI4UuJTWuBI5rmHhgRL5RWyr 9wwmIr1RzElg== X-IronPort-AV: E=Sophos;i="5.82,252,1613462400"; d="scan'208";a="447353469" Received: from ssumanpx-mobl.amr.corp.intel.com (HELO skuppusw-mobl5.amr.corp.intel.com) ([10.254.34.197]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2021 11:02:58 -0700 From: Kuppuswamy Sathyanarayanan To: Peter Zijlstra , Andy Lutomirski , Dave Hansen , Dan Williams , Tony Luck Cc: Andi Kleen , Kirill Shutemov , Kuppuswamy Sathyanarayanan , Raj Ashok , Sean Christopherson , linux-kernel@vger.kernel.org, Isaku Yamahata , Kuppuswamy Sathyanarayanan Subject: [RFC v2 32/32] x86/tdx: ioapic: Add shared bit for IOAPIC base address Date: Mon, 26 Apr 2021 11:01:59 -0700 Message-Id: <4e6bcc4dd2b21b441fb7a9e4ae1bc4f309621c7a.1619458733.git.sathyanarayanan.kuppuswamy@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Isaku Yamahata IOAPIC is emulated by KVM which means its MMIO address is shared by host. Add shared bit for base address of IOAPIC. Most MMIO region is handled by ioremap which is already marked as shared for TDX guest platform, but IOAPIC is an exception which uses fixed map. Signed-off-by: Isaku Yamahata Reviewed-by: Andi Kleen Signed-off-by: Kuppuswamy Sathyanarayanan --- arch/x86/kernel/apic/io_apic.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index 73ff4dd426a8..2a01d4a82be7 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c @@ -2675,6 +2675,14 @@ static struct resource * __init ioapic_setup_resources(void) return res; } +static void io_apic_set_fixmap_nocache(enum fixed_addresses idx, phys_addr_t phys) +{ + pgprot_t flags = FIXMAP_PAGE_NOCACHE; + if (is_tdx_guest()) + flags = pgprot_tdg_shared(flags); + __set_fixmap(idx, phys, flags); +} + void __init io_apic_init_mappings(void) { unsigned long ioapic_phys, idx = FIX_IO_APIC_BASE_0; @@ -2707,7 +2715,7 @@ void __init io_apic_init_mappings(void) __func__, PAGE_SIZE, PAGE_SIZE); ioapic_phys = __pa(ioapic_phys); } - set_fixmap_nocache(idx, ioapic_phys); + io_apic_set_fixmap_nocache(idx, ioapic_phys); apic_printk(APIC_VERBOSE, "mapped IOAPIC to %08lx (%08lx)\n", __fix_to_virt(idx) + (ioapic_phys & ~PAGE_MASK), ioapic_phys); @@ -2836,7 +2844,7 @@ int mp_register_ioapic(int id, u32 address, u32 gsi_base, ioapics[idx].mp_config.flags = MPC_APIC_USABLE; ioapics[idx].mp_config.apicaddr = address; - set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address); + io_apic_set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address); if (bad_ioapic_register(idx)) { clear_fixmap(FIX_IO_APIC_BASE_0 + idx); return -ENODEV; -- 2.25.1