From patchwork Fri Dec 9 01:53:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 31588 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp529736wrr; Thu, 8 Dec 2022 17:57:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf4lc2WmD9lt/P6qq9whoWuYCwhj34eVSTwHnxQGPwHybf46ezw0qvtJwXdg6+dCs8JDi9Dq X-Received: by 2002:a05:6402:3985:b0:461:3ae6:8bfc with SMTP id fk5-20020a056402398500b004613ae68bfcmr4060970edb.34.1670551058544; Thu, 08 Dec 2022 17:57:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670551058; cv=none; d=google.com; s=arc-20160816; b=Rl9glNCj/W/rEXUbrIMd1uYR2mWWWkUaMvTb2l5hLfk4LUI2Mi1xQ9LjpVeZUVJVgO q/V5HNIkxirARBWNlpBYTvaPJLqk8ydjHnINDyi7zq2l4eKzzC3lkX61Oeyv/XLWJN/g HEGqsTW/4QH5wqpenMpyQhy4aNzn8JRdwWhzHigkK77nfJzidjiM0+CobpH+XoymjxN4 2Q5dJYd+UQI9POtVoP1idR3mFPbqKMytnbVkSfwIctbfK0ob2/ZmZLwpzc1sLWn+uDb9 63dLU+iQLcgoRQJq/JTAmq65/kaEuMwLM9Xf5U63iRigSl4KQjfW9kwN3BCOz0vEq9NA Z4sA== 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=iNaQ8cVFg6rq2AduHYUK2UWrWd1BcZJaAQrRI7/Dw7A=; b=UZmTfLWsQezFhJbX+dnHD9xrikMJMpfKD+LKC/UHxesWM0lUN7FOsmi6L5Ls1eNdxh 8tU41bnvqfDIKLs2Qre3f2sfS4YHUZDM1+Mok2sYZtyydaSxgRMiQhac7fk1zyiTDyLl bkYDvkw/lz18lUMNRdst3DQWLtrcfIqZ56yGie7oOJmfyojFBlFLgX92oT+kZjuZadrI +8EZpT7Ri7v2qAMHJmotkEr1ST953O/IeV9IMynpr4nqOr8Pmjloe/T2EYbPdZRzmcRG 2/S32HcS0BEPhy1T0dB7AmyafcZV4MmQDp0XmaihXKRFVdGkpJUHRYMHve+iz0Jtz445 3ACQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z10-20020a05640235ca00b0046b9f6d9a96si305820edc.280.2022.12.08.17.57.15; Thu, 08 Dec 2022 17:57:38 -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 S229997AbiLIBxk (ORCPT + 99 others); Thu, 8 Dec 2022 20:53:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229813AbiLIBxe (ORCPT ); Thu, 8 Dec 2022 20:53:34 -0500 Received: from out-233.mta0.migadu.com (out-233.mta0.migadu.com [IPv6:2001:41d0:1004:224b::e9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A441D941AB for ; Thu, 8 Dec 2022 17:53:32 -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 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 Subject: [PATCH v2 2/7] KVM: selftests: Setup ucall after loading program into guest memory Date: Fri, 9 Dec 2022 01:53:01 +0000 Message-Id: <20221209015307.1781352-3-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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751699746818484052?= X-GMAIL-MSGID: =?utf-8?q?1751699746818484052?= The new ucall infrastructure needs to update a couple of guest globals to pass through the ucall MMIO addr and pool of ucall structs. A precondition of writing to the guest's program image is to have it already loaded into guest memory. Call ucall_init() after kvm_vm_elf_load(). Continue to park the ucall MMIO addr after MEM_REGION_TEST_DATA. Signed-off-by: Oliver Upton --- tools/testing/selftests/kvm/aarch64/page_fault_test.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/aarch64/page_fault_test.c b/tools/testing/selftests/kvm/aarch64/page_fault_test.c index 92d3a91153b6..95d22cfb7b41 100644 --- a/tools/testing/selftests/kvm/aarch64/page_fault_test.c +++ b/tools/testing/selftests/kvm/aarch64/page_fault_test.c @@ -609,8 +609,13 @@ static void setup_memslots(struct kvm_vm *vm, struct test_params *p) data_size / guest_page_size, p->test_desc->data_memslot_flags); vm->memslots[MEM_REGION_TEST_DATA] = TEST_DATA_MEMSLOT; +} + +static void setup_ucall(struct kvm_vm *vm) +{ + struct userspace_mem_region *region = vm_get_mem_region(vm, MEM_REGION_TEST_DATA); - ucall_init(vm, data_gpa + data_size); + ucall_init(vm, region->region.guest_phys_addr + region->region.memory_size); } static void setup_default_handlers(struct test_desc *test) @@ -702,6 +707,7 @@ static void run_test(enum vm_guest_mode mode, void *arg) vm = ____vm_create(mode); setup_memslots(vm, p); kvm_vm_elf_load(vm, program_invocation_name); + setup_ucall(vm); vcpu = vm_vcpu_add(vm, 0, guest_code); setup_gva_maps(vm);