Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp173687lqr; Wed, 5 Jun 2024 02:33:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU90m1jPVMZPbQSgoV8w6sAiQwab+6Ftu7eEbqKkKO+5IDrzbdHinSSwhsrMGaDw4znhCKq7/tWVdy9dwiwqVmwYLn5ck4xuCJ1P+clcg== X-Google-Smtp-Source: AGHT+IGQhCsHZK4F4QCQ7kYlPD7KXCZQaNPuaKCeSKMqN/eNHYon0M7PmeQVZhcjMpNxw0X6jYlJ X-Received: by 2002:a05:620a:45a0:b0:794:ad5e:c02a with SMTP id af79cd13be357-79523fbeb28mr255288485a.47.1717580018235; Wed, 05 Jun 2024 02:33:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717580018; cv=pass; d=google.com; s=arc-20160816; b=hOiIj22om351MUp5lY1n3imA7nAbAz4FWk3tJRYZPs3IQuCbuLoQtdozSlBtEaW4bB an76YdWq7h2wnHu/zrlypIgDJLKKLKrtWmOl3Mhvy0IvumUTrgg9cjocXFDKHz0+bhUz +rNvL03bzHq+pa9dTF00I38a1uuN646YCNrqnO+I+g1N2ZpCH4Ak6+SKrqZ/QE4XyGte wkTOM8S2kT9qGqYQbuV9p8ZOU3Y0yo+DD+3i2lswVCWcXw+si2jXk0cEsmy1vVEl936J H2TDldR9iY+McTLjxI3Nkv246tGOnxem2OgHYCC4JBR2eXsx93vu5Dzdnq0OB8S1jSvK +Wuw== 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=PnVFYiMNad9DXqD1ls58tFPItMgb4VrE16cE6Za+jac=; fh=mU6xl5FN63PgqIKyLHx/u5uRervM0V89cYoVjXl22Bs=; b=Qh9ipa5VyBQG+hj164/Vm0/ZxSnP6EA+Ca75pz+d2MSVJupyi5/8Wz6ZGqLSrAleD/ lmKPinCjdgBSfrUM3j8dzdxP2j816p477z3i890xjykl6hs+RcSDPn6Wdgau/WcK6xVJ 8AzAGdTJCwAaROBhwWUylDlhlH9Vs8+Q3oGhVXcvhroN0XTGDqpgy698SH5jXRPHQs9i wFfM8E13jyTt8QipMv4IIljR1aN1+R78A3JUydvNy9UkIUmX2VmaIllmdvp0KQ4iNTJp /v9vchJbn184oUgrvm+YMkOU0C3B1ZVgI+uAULq0UNXNZ906NTT9+YWFFF7ClAFJCr61 lBUg==; 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-202105-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202105-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-794f2e603ccsi1405965585a.0.2024.06.05.02.33.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 02:33:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202105-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::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-202105-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202105-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 4B6831C239AF for ; Wed, 5 Jun 2024 09:33:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E4FCF19309B; Wed, 5 Jun 2024 09:30:45 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1F058372; Wed, 5 Jun 2024 09:30:44 +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=1717579845; cv=none; b=Q+UK3n7SCU3OseSdCbQhsZJZe4TEnI1JZF4KP88ZfH7DVTllY/lf4XZ5qLEjILxKlo6lKHv3DUWEm1+7fUtMkMgwa2c82/uRZH+/fBlvVOhr8Pb3YldJiMG4ec05eXP4gAeflDALDpoSC0AZgMxDIB1XHh+7XZK2cZQyKB1VPZc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717579845; c=relaxed/simple; bh=s2vOUxjeosu1gEgyj3P2k8asQzqeV+ifF6wb935eHms=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LrW70oc2aE56NNssJJjEXTKoPlKi991P1MSDzJszNqL3vq0ug58LVGb59Q7BA+rCTubY5Hw29EJ78+PvX/1Me9g/EaHo5fmcsVJAol7xBI3qqehCLdaxe1oMxpC5L40Xkgh294jiewuxo+skWETr65DMaN/yka1eYPMPUv7UJg4= 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 302A2DA7; Wed, 5 Jun 2024 02:31:08 -0700 (PDT) Received: from e122027.arm.com (unknown [10.57.39.129]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 225803F792; Wed, 5 Jun 2024 02:30:39 -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 v3 06/14] arm64: Override set_fixmap_io Date: Wed, 5 Jun 2024 10:29:58 +0100 Message-Id: <20240605093006.145492-7-steven.price@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240605093006.145492-1-steven.price@arm.com> References: <20240605093006.145492-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. If/when support for device assignment and device emulation in the realm is added in the future then this will need to 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 c927e9312f10..9123df312842 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -1192,6 +1192,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