From patchwork Wed Dec 7 21:48:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 31061 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp419618wrr; Wed, 7 Dec 2022 13:49:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf4f3WzAW8xKHqcX6B2woP111BDpnn0xz75Uv9sXTJfe5hToA1bV4PcjUt9dm7pSC8rU8c6W X-Received: by 2002:a17:90a:7d0f:b0:219:7ec6:8f3f with SMTP id g15-20020a17090a7d0f00b002197ec68f3fmr31984595pjl.103.1670449763359; Wed, 07 Dec 2022 13:49:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670449763; cv=none; d=google.com; s=arc-20160816; b=Z7p1NJZ0VlVaxxyZeE6+oL31UVvz7NvG+bYn/ftgIkCH1PQ+4iRds5RHKzJH4Jygzv nBUXaGDWPJYmQoU3/+mRZvYoqBBMa+xO/wdW1levMlEaa/Vp9A7MaIYQvMasO1b+uZsa MnWjmG5Dk4Jav6mzvgQ9AkNjQ7swTnojlJS0JsLmk7tgXwOXxCFz5E0irVT1R2uXaTb+ vH79M6Hd7EpVjtHHZYRK/uCUImvjo1de/4oSMIN35olLicDOp8YM9J3W74sYNOR6FLYk fak6LFhiqSXze7ZjOsl++uRbNGJ6BOztrgOQLuOcDvFX4xPXtPY/qb6w5VAgzg2rXQcI O/lg== 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 :dkim-signature; bh=MEqt5cwx0S15sf2YghjqjZFjTELYz7+UvtRN6GGMw7I=; b=diZqqBjY2VmijudmHd12yGRgHC/el41fN973r7vSxIuL7Lu0riTNkbJ+UpBvpgCkaM FmLIi6W37GOVj8CJP1PS74pse0xylEQDllj6n+SK7AetASTuZkYkXhCMyXrK//7kjMWQ Z5d2KhhRd9Ac+sxlDUiCEdjHZngfeQPh5/EiBewv4R+Rvd1beOcLAM1fhkmCu0NRca+r 1NQQs0VYXi9q53f0UVV/5ao5V8TuQtVpEdAnChkYDKWuKt7jce+R2tMT7FvQ/LPxEQZK fKRR0FwoasHycqWX85y0F89u63h6evACQc3/N5Xz061OMDGKF8FG3+UcIGMeKCDB4sYj hALw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=cQONTD5L; 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=pass (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 u63-20020a638542000000b00478c967a84esi8009783pgd.748.2022.12.07.13.49.10; Wed, 07 Dec 2022 13:49:23 -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; dkim=pass header.i=@linux.dev header.s=key1 header.b=cQONTD5L; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229849AbiLGVsg (ORCPT + 99 others); Wed, 7 Dec 2022 16:48:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229786AbiLGVsa (ORCPT ); Wed, 7 Dec 2022 16:48:30 -0500 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89BF770621; Wed, 7 Dec 2022 13:48:29 -0800 (PST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1670449708; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MEqt5cwx0S15sf2YghjqjZFjTELYz7+UvtRN6GGMw7I=; b=cQONTD5LZyqBsrtyfAIp6nhc/p6dWCYdUqkUQwQscaRAqQtFUeKmqYCwMi5pNhGkO185OJ z7W0qhvRCaBG3DpfD+7TImes/kV6AH/VeDa0FniNFFhBY1IllL9mFb4rei5w+klHTmRdH+ OxJ5Rrx1dJtNznZVukhm+TFkPPxdLFw= 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 2/4] KVM: selftests: Setup ucall after loading program into guest memory Date: Wed, 7 Dec 2022 21:48:06 +0000 Message-Id: <20221207214809.489070-3-oliver.upton@linux.dev> In-Reply-To: <20221207214809.489070-1-oliver.upton@linux.dev> References: <20221207214809.489070-1-oliver.upton@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751593531439736386?= X-GMAIL-MSGID: =?utf-8?q?1751593531439736386?= 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 this actually working is to have the program image 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);