Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1975606rwb; Thu, 8 Dec 2022 18:20:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf5tQ31ha0MI3z3SMWnnR0pzKa1wNLPUDz1bYbs2SllcD4dUXHG4eZklYVKJhKkao0t9ECER X-Received: by 2002:a17:902:e8d7:b0:189:413a:9d76 with SMTP id v23-20020a170902e8d700b00189413a9d76mr3841094plg.47.1670552421654; Thu, 08 Dec 2022 18:20:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670552421; cv=none; d=google.com; s=arc-20160816; b=JpbuYk7fHymyW52QumcO26Lhddne9XSS1Z7EBoJ2P/+3bascJsmGbLwF19wPQZN/WO y6cPPB2s/p6oDHOtwe4M+gTgSmfb8JIVFkTvPf0md8YWeKO63AFa9hvKNK+ZsfL6Epnf MdTlas8O1/UybzjsL+WoW5COC/+OmkM6hJTgH6SPYCOkHGUWRJSJfHr+F2OMiwoAYSx2 L0lHiuHEZTB9TwcVguidKVEcoZ/7Lv8qkLpOTVWbb/BUn+2UdQlGpzZ/YI61Zcq1WklK ZU3kWqZGWh0e1+hQH5zy4wvI6lHAeyFseyZwuMqxe4x4X72W4RU6IcsVHlpA0zGebBPt k1VA== 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; bh=qZMCjgWfjbfYBycq79hF9R9CkWiOAgpLZz+FN8edLKs=; b=k6DCnbiZEVUn8vMkrqox3D8wTODdJzcU1Q/A5ykrnXrgq/TuQYkCcdlukFvDY7kqIR LBohfBXWZs3MlYgHt20+pRRvZmh22KARKpCrRazIYrVPrJfbZ6XCBnKuNGBo9PDAmNc6 UK55Ck5KPvuUJuiyCXYHsp22iTlxnp+/Mb5okBHqW2NMjG9HBESohTCU4qQUCJRQgLG3 XHnW9/f8jcukSUJqPQ7TxbE5CgLkSvOK/FqzO9U8ey/rVb881lqp8mqaAhswHjykSfLw VFOGq49hFiUJ3EmrBgtelY8i0SuQYoP1ouztgXagDOPJCTyU0WdCixJGfGrRYsP4Z9dz EMFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z17-20020a170902d55100b0017d6ffda9e3si326335plf.369.2022.12.08.18.20.12; Thu, 08 Dec 2022 18:20:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230139AbiLIByL (ORCPT + 73 others); Thu, 8 Dec 2022 20:54:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230053AbiLIBxu (ORCPT ); Thu, 8 Dec 2022 20:53:50 -0500 Received: from out-155.mta0.migadu.com (out-155.mta0.migadu.com [IPv6:2001:41d0:1004:224b::9b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F034944DA for ; Thu, 8 Dec 2022 17:53:42 -0800 (PST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Oliver Upton , Paolo Bonzini , Shuah Khan , Nathan Chancellor , Nick Desaulniers , Tom Rix Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, kvmarm@lists.linux.dev, Ricardo Koller , Sean Christopherson , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH v2 5/7] KVM: arm64: selftests: Don't identity map the ucall MMIO hole Date: Fri, 9 Dec 2022 01:53:04 +0000 Message-Id: <20221209015307.1781352-6-oliver.upton@linux.dev> In-Reply-To: <20221209015307.1781352-1-oliver.upton@linux.dev> References: <20221209015307.1781352-1-oliver.upton@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently the ucall MMIO hole is placed immediately after slot0, which is a relatively safe address in the PA space. However, it is possible that the same address has already been used for something else (like the guest program image) in the VA space. At least in my own testing, building the vgic_irq test with clang leads to the MMIO hole appearing underneath gicv3_ops. Stop identity mapping the MMIO hole and instead find an unused VA to map to it. Yet another subtle detail of the KVM selftests library is that virt_pg_map() does not update vm->vpages_mapped. Switch over to virt_map() instead to guarantee that the chosen VA isn't to something else. Signed-off-by: Oliver Upton --- tools/testing/selftests/kvm/lib/aarch64/ucall.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/kvm/lib/aarch64/ucall.c b/tools/testing/selftests/kvm/lib/aarch64/ucall.c index 562c16dfbb00..f212bd8ab93d 100644 --- a/tools/testing/selftests/kvm/lib/aarch64/ucall.c +++ b/tools/testing/selftests/kvm/lib/aarch64/ucall.c @@ -14,11 +14,13 @@ static vm_vaddr_t *ucall_exit_mmio_addr; void ucall_arch_init(struct kvm_vm *vm, vm_paddr_t mmio_gpa) { - virt_pg_map(vm, mmio_gpa, mmio_gpa); + vm_vaddr_t mmio_gva = vm_vaddr_unused_gap(vm, vm->page_size, KVM_UTIL_MIN_VADDR); + + virt_map(vm, mmio_gva, mmio_gpa, 1); vm->ucall_mmio_addr = mmio_gpa; - write_guest_global(vm, ucall_exit_mmio_addr, (vm_vaddr_t *)mmio_gpa); + write_guest_global(vm, ucall_exit_mmio_addr, (vm_vaddr_t *)mmio_gva); } void ucall_arch_do_ucall(vm_vaddr_t uc) -- 2.39.0.rc1.256.g54fd8350bd-goog