Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp13583lql; Fri, 12 Apr 2024 01:57:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXk5YHIoTyYPSt0OUkiFJ2Rmc5UUh+gw9mUpZEhhaWd0eezhSFr+MXJOxG2v6V55RcQXWiip72luRbIrlzke7HD2P2JX2+mvyCC3CCbBQ== X-Google-Smtp-Source: AGHT+IEmi0GVfPtE8GmLPktlCrassO9Q2n37KsZw3AfRli1XLa6jYrnUZIzU+WzS6GcZZiUSAbER X-Received: by 2002:a19:5509:0:b0:513:e369:cc41 with SMTP id n9-20020a195509000000b00513e369cc41mr1429731lfe.49.1712912250505; Fri, 12 Apr 2024 01:57:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712912250; cv=pass; d=google.com; s=arc-20160816; b=gO20domdOrVb3Ux1/K/s/w2IYRPwUGd97BeezkCPmIRIkxGO3lDU+wNPEtuYCxwUgp XT+oW+kJfzkizAbjv1GUeri5Idccr1Vkv/Yfbi3v+d/msUlZ7mj0d+QklYYjVB8kRLNM weyguI28f8+HZLKDsHaUVLDn3U3hUV9IslAFhatq0zWqpj/XIFnPbc7AH9qVOyI9N5vf AKl+99OLIgAYk4B/F0pJr0/ldxSMLX8dfM51/m8MqANY5qfjOszKoBdLwDN4udXqa1ej Z0IEtE1t6/JI/dGfy5IEGPCZtK1stQF7T1EalU//4MU/vGYDBMlbGvsTshjh2eX8a8xI guUg== 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=+Px4nY2+U9rcJmN5NAvnz9bJln/0Dq8Ku02VgohUed0=; fh=NDCPdPn2hiqHaiIRDYQAzsW9PK20CTia4nECGof6enU=; b=nCFBmsgO59WUHzx2/LyGKxfr4IShQp+ght9vkqelueWz3YexIibuxbNcNLddHw57ZX D1CxO6Y9pKUYuPVy9Etupdj3uzJCs2mm9tTakT0BpEBnihxjcJvBNqH47mKn2cQwYeMs hwDyEhWifQJ4ehtDRYWq+xYIbljBvXTgJK+K8kKAp5uedXYDqZez9zXn1GWw3cTI2vVe DqSiAzOfXuRTFgzjbw8IcU20p4L5EYyZwgomLdqRrgJL8XzLXgPWRAiAZy5+9Dk/KTUR X8vQRxNqnBbeFlO8nMzPwS6okHwt5vdZOYQfjNMVU7CaY6Z8occ6DgjTFRcS3Y8x5DVU MWdw==; 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-142300-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142300-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a2-20020a170906244200b00a51ca3e2ea6si1489636ejb.257.2024.04.12.01.57.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 01:57:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142300-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; 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-142300-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142300-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3A8871F22530 for ; Fri, 12 Apr 2024 08:57:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5E99712BEB8; Fri, 12 Apr 2024 08:44:32 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 67EF454BEA; Fri, 12 Apr 2024 08:44:29 +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=1712911471; cv=none; b=o/ZJ3eWUbnsYjwGbmxpNe5pwoumJB26fnNHWTlBiqFPvdTYkI1feY+eVwSKW7TbJ3eYuI/C7ddhaWF5WCaVs1DMoQSyAZ8LEag1mQWbRnSLAJDLCMs5Q2LVnap+Ukyn652zDTHrHekRsv8GDUN2ok7SDxiGR+pHPD2rtMujdjHM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712911471; c=relaxed/simple; bh=gPJlmtDy22gszZA3O13BsHOgi4mXz2DnvFcZ2sEUWV4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TSSouCmocOPXr/tmWTnP4EeWVlOYSU6TqRlb8IbADu+SJbk6hdNf1Yt01pTngUHqOie75VNq33ZjtgZciQy3TM0mRI8oiL2obXGKFgRAzRgOCgEJieKWEe5qBJxUxpm5DtqAd+6zmVvrzpi3iBKrtHitEx50meBE3wlzyeGJsBM= 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 347191596; Fri, 12 Apr 2024 01:44:58 -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 CC8483F6C4; Fri, 12 Apr 2024 01:44:26 -0700 (PDT) From: Steven Price To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: Steven Price , Catalin Marinas , Marc Zyngier , Will Deacon , James Morse , Oliver Upton , Suzuki K Poulose , 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 Subject: [PATCH v2 30/43] arm64: RME: Always use 4k pages for realms Date: Fri, 12 Apr 2024 09:42:56 +0100 Message-Id: <20240412084309.1733783-31-steven.price@arm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240412084309.1733783-1-steven.price@arm.com> References: <20240412084056.1733704-1-steven.price@arm.com> <20240412084309.1733783-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 Always split up huge pages to avoid problems managing huge pages. There are two issues currently: 1. The uABI for the VMM allows populating memory on 4k boundaries even if the underlying allocator (e.g. hugetlbfs) is using a larger page size. Using a memfd for private allocations will push this issue onto the VMM as it will need to respect the granularity of the allocator. 2. The guest is able to request arbitrary ranges to be remapped as shared. Again with a memfd approach it will be up to the VMM to deal with the complexity and either overmap (need the huge mapping and add an additional 'overlapping' shared mapping) or reject the request as invalid due to the use of a huge page allocator. For now just break everything down to 4k pages in the RMM controlled stage 2. Signed-off-by: Steven Price --- arch/arm64/kvm/mmu.c | 4 ++++ arch/arm64/kvm/rme.c | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 50a49e4e2020..d891fc3c1a10 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1532,6 +1532,10 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, if (logging_active) { force_pte = true; vma_shift = PAGE_SHIFT; + } else if (kvm_is_realm(kvm)) { + // Force PTE level mappings for realms + force_pte = true; + vma_shift = PAGE_SHIFT; } else { vma_shift = get_vma_page_shift(vma, hva); } diff --git a/arch/arm64/kvm/rme.c b/arch/arm64/kvm/rme.c index 9593e8e35913..ae9fd12c4e7d 100644 --- a/arch/arm64/kvm/rme.c +++ b/arch/arm64/kvm/rme.c @@ -847,7 +847,9 @@ static int populate_par_region(struct kvm *kvm, break; } - if (is_vm_hugetlb_page(vma)) + // FIXME: To avoid the overmapping issue (see below comment) + // force the use of 4k pages + if (is_vm_hugetlb_page(vma) && 0) vma_shift = huge_page_shift(hstate_vma(vma)); else vma_shift = PAGE_SHIFT; -- 2.34.1