Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp13502lql; Fri, 12 Apr 2024 01:57:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUI2JjkmaCBQgSZlCCD+rcKoTypiC+FRsxOOFYb3jwhrgy3Rjac3JekC4Ef+1z4CV1AmqaaXKb9XCwd1rtWpa5ZGFo025/uJQeAdNA0Wg== X-Google-Smtp-Source: AGHT+IGfNJ9JP9LR7ZV9seKZ8nPBX2L2KdDZBmL65RbFPOhBPUbZ/XCFSsQPxQVzCctz7tLkP5BO X-Received: by 2002:a17:902:e80d:b0:1e2:abc5:e28b with SMTP id u13-20020a170902e80d00b001e2abc5e28bmr3136912plg.19.1712912233633; Fri, 12 Apr 2024 01:57:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712912233; cv=pass; d=google.com; s=arc-20160816; b=WJ9ugPinatCDj6jHeKyJm90vdH/JOulJcqTAQYdQqyRxPisY8EH157ibQpodDT5cpT Lpa095WihyMAEAD6odOmWmR/T7GTHX+TO3BRNr/bwFqNfDeebHp9fv+yzOu08xkrQtJ2 K/VUPG+C7ARZC++6smBYpL08NTYEhZQ2h1IAW9piusVMvoGEPCUfgmYhchu9wSTyFm9k Ib2f+s8eycvdvRpx8jjArulZ0MLbOuOVtefadEvQsQwMXiu1slOs1Zt1Bfc+8svrEMiS btxloNL5LPJxXWocjJrgYysSxVFy6sqv3E8SysjDrtcZ2O/WIsxjtwUGSlbT0o/St4Zc iKgg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=APtPS0zNFVXOoDy3z91AXIBtbv0vr+2x5MQdb3wFteU=; fh=mU6xl5FN63PgqIKyLHx/u5uRervM0V89cYoVjXl22Bs=; b=ez9zuJ5ddgvetCV2Sh57Hhc73Z8M4pfT9mnJcIfo9lvFdK0cV6ksh9/p9rhs/Px0LQ 4wXKkBXpwGizJX7OKYQLBrCGpKsjDkCuL0tIpnKxth8B2E0mNCs+NKhbD9S7o1qGrmqD smzt2P7UQkQHCeZnInmxfWMRDvaQN0O2WGdlJwZ6I0PyTrN6mfRWImWSilMVMCc00NWC DtCLJBK6jCiQX9wQzfdvnWxZDPFCQSLg0aPHU9e8fuTfA4dqelD9v7NENoP1loRIvgkq UFsqqzWTFjorGM+2V97jRf1aIvIXEOu8eKwT7KLB9vMl4TxAjjF4ko1I1RfmipEbDR0U NrSw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-142259-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142259-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id bf6-20020a170902b90600b001e48565b405si2671506plb.522.2024.04.12.01.57.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 01:57:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142259-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-142259-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142259-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 13424B25EEC for ; Fri, 12 Apr 2024 08:44:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E5E06548E3; Fri, 12 Apr 2024 08:42:37 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2FFEC5491E; Fri, 12 Apr 2024 08:42:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712911357; cv=none; b=a/6RRxOSk44jEp8IG2rg6vSNoujFHpi+hVvwPC4ZTY5rY0Qlfo5/nZUbgnPRwAoF/92qn0YBRPO8eym4rxxgQ5hKrlVteyeAFSp408MW+IInNWpIDWkyo0yVLF6tGlNPH1BwAedUyKuJDlvNQYeL86afE6e7dcHfkPR5KZVzy2o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712911357; c=relaxed/simple; bh=NzTq93Hq8EFgm3RsLWJO2q7JPk/z+1u4hBvkebGpVoQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Y9uw63Dn1nTICHIVbsOCQ8WaeyrnhHJs4H0zf43JI0OzC9y+T4I5z2OACFXbLYB4OwRC7hiHxbe152SXT+iHlCx3Kc9M+p2lS7hqQMEMqyVCpHOTbA+OdajtOAecgLq106kAknyI7M7h+klf6rLCzL7mg/A9CT8Jy8x8ueylhU0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 21CD414BF; Fri, 12 Apr 2024 01:43:05 -0700 (PDT) Received: from e112269-lin.cambridge.arm.com (e112269-lin.cambridge.arm.com [10.1.194.51]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BCBE73F6C4; Fri, 12 Apr 2024 01:42:33 -0700 (PDT) From: Steven Price To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: Suzuki K Poulose , Catalin Marinas , Marc Zyngier , Will Deacon , James Morse , Oliver Upton , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Joey Gouly , Alexandru Elisei , Christoffer Dall , Fuad Tabba , linux-coco@lists.linux.dev, Ganapatrao Kulkarni , Steven Price Subject: [PATCH v2 06/14] arm64: Override set_fixmap_io Date: Fri, 12 Apr 2024 09:42:05 +0100 Message-Id: <20240412084213.1733764-7-steven.price@arm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240412084213.1733764-1-steven.price@arm.com> References: <20240412084056.1733704-1-steven.price@arm.com> <20240412084213.1733764-1-steven.price@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Suzuki K Poulose Override the set_fixmap_io to set shared permission for the host in case of a CC guest. For now we mark it shared unconditionally. Future changes could filter the physical address and make the decision accordingly. Signed-off-by: Suzuki K Poulose Signed-off-by: Steven Price --- arch/arm64/include/asm/fixmap.h | 4 +++- arch/arm64/mm/mmu.c | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/fixmap.h b/arch/arm64/include/asm/fixmap.h index 87e307804b99..f765943b088c 100644 --- a/arch/arm64/include/asm/fixmap.h +++ b/arch/arm64/include/asm/fixmap.h @@ -107,7 +107,9 @@ void __init early_fixmap_init(void); #define __late_set_fixmap __set_fixmap #define __late_clear_fixmap(idx) __set_fixmap((idx), 0, FIXMAP_PAGE_CLEAR) -extern void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot); +#define set_fixmap_io set_fixmap_io +void set_fixmap_io(enum fixed_addresses idx, phys_addr_t phys); +void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot); #include diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 495b732d5af3..79d84db9ffcb 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -1179,6 +1179,19 @@ void vmemmap_free(unsigned long start, unsigned long end, } #endif /* CONFIG_MEMORY_HOTPLUG */ +void set_fixmap_io(enum fixed_addresses idx, phys_addr_t phys) +{ + pgprot_t prot = FIXMAP_PAGE_IO; + + /* + * For now we consider all I/O as non-secure. For future + * filter the I/O base for setting appropriate permissions. + */ + prot = __pgprot(pgprot_val(prot) | PROT_NS_SHARED); + + return __set_fixmap(idx, phys, prot); +} + int pud_set_huge(pud_t *pudp, phys_addr_t phys, pgprot_t prot) { pud_t new_pud = pfn_pud(__phys_to_pfn(phys), mk_pud_sect_prot(prot)); -- 2.34.1