Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD8F8C4332F for ; Fri, 15 Oct 2021 12:52:24 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5CA4560230 for ; Fri, 15 Oct 2021 12:52:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5CA4560230 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.210479.367386 (Exim 4.92) (envelope-from ) id 1mbMh3-0001up-J0; Fri, 15 Oct 2021 12:52:13 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 210479.367386; Fri, 15 Oct 2021 12:52:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mbMh3-0001uQ-FF; Fri, 15 Oct 2021 12:52:13 +0000 Received: by outflank-mailman (input) for mailman id 210479; Fri, 15 Oct 2021 12:52:12 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mbMh1-0001If-US for xen-devel@lists.xenproject.org; Fri, 15 Oct 2021 12:52:11 +0000 Received: from smtp-out1.suse.de (unknown [195.135.220.28]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id b1a31ad2-2db6-11ec-8235-12813bfff9fa; Fri, 15 Oct 2021 12:52:03 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B262A21974; Fri, 15 Oct 2021 12:52:02 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 66E0713C1A; Fri, 15 Oct 2021 12:52:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0HjvF3J5aWEYHgAAMHmgww (envelope-from ); Fri, 15 Oct 2021 12:52:02 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b1a31ad2-2db6-11ec-8235-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1634302322; h=from:from:reply-to: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=JZRlGSWF2EiK/LbFLLQovLWJFg0uUM6yzYNKwQso+lM=; b=BKDQA57PMur/hYqQjSuqmz0yuLXcRgI6ISZITcdgrkEPIBu12bsKVYzxxriK7NfAOp5EGM /zE3l+poi18A7I+OGjR7MuB8+A/V5vJ+J+xy2ch89Z2xrHBViYmSRx/NL3G66tZV1lJ9SU UVhm9nhhKPwAMsyiq2YZUisJAc0xZTI= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Wei Liu , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 02/12] xen: move do_vcpu_op() to arch specific code Date: Fri, 15 Oct 2021 14:51:42 +0200 Message-Id: <20211015125152.25198-3-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20211015125152.25198-1-jgross@suse.com> References: <20211015125152.25198-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Today Arm is using another entry point for the vcpu_op hypercall as x86, as some of the common sub-ops are not supported on Arm. The Arm specific handler filetrs out the not supported sub-ops and then calls the common handler. This leads to the weird call hierarchy: do_arm_vcpu_op() do_vcpu_op() arch_do_vcpu_op() Clean this up by renaming do_vcpu_op() to common_vcpu_op() and arch_do_vcpu_op() in each architecture to do_vcpu_op(). This way one of above calls can be avoided without restricting any potential future use of common sub-ops for Arm. Additionally the single user of HYPERCALL_ARM() can be modified and HYPERCALL_ARM() can be removed. Signed-off-by: Juergen Gross --- xen/arch/arm/domain.c | 15 ++++++++------- xen/arch/arm/traps.c | 7 +------ xen/arch/x86/domain.c | 11 +++++++---- xen/arch/x86/x86_64/domain.c | 16 ++++++++++++---- xen/common/compat/domain.c | 14 ++++++-------- xen/common/domain.c | 11 ++++------- xen/include/asm-arm/hypercall.h | 2 -- xen/include/asm-x86/hypercall.h | 2 +- xen/include/xen/hypercall.h | 2 +- 9 files changed, 40 insertions(+), 40 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index eef0661beb..d20a972b51 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -1070,23 +1070,24 @@ void arch_dump_domain_info(struct domain *d) } -long do_arm_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg) +long do_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg) { + struct domain *d = current->domain; + struct vcpu *v; + + if ( (v = domain_vcpu(d, vcpuid)) == NULL ) + return -ENOENT; + switch ( cmd ) { case VCPUOP_register_vcpu_info: case VCPUOP_register_runstate_memory_area: - return do_vcpu_op(cmd, vcpuid, arg); + return common_vcpu_op(cmd, v, arg); default: return -EINVAL; } } -long arch_do_vcpu_op(int cmd, struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg) -{ - return -ENOSYS; -} - void arch_dump_vcpu_info(struct vcpu *v) { gic_dump_info(v); diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 219ab3c3fb..7abc28848e 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -1351,11 +1351,6 @@ typedef struct { .nr_args = _nr_args, \ } -#define HYPERCALL_ARM(_name, _nr_args) \ - [ __HYPERVISOR_ ## _name ] = { \ - .fn = (arm_hypercall_fn_t) &do_arm_ ## _name, \ - .nr_args = _nr_args, \ - } /* * Only use this for hypercalls which were deprecated (i.e. replaced * by something else) before Xen on ARM was created, i.e. *not* for @@ -1386,7 +1381,7 @@ static arm_hypercall_t arm_hypercall_table[] = { #endif HYPERCALL(multicall, 2), HYPERCALL(platform_op, 1), - HYPERCALL_ARM(vcpu_op, 3), + HYPERCALL(vcpu_op, 3), HYPERCALL(vm_assist, 2), #ifdef CONFIG_ARGO HYPERCALL(argo_op, 5), diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index ef1812dc14..e1440ec2f5 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1488,11 +1488,14 @@ int arch_vcpu_reset(struct vcpu *v) return 0; } -long -arch_do_vcpu_op( - int cmd, struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg) +long do_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg) { long rc = 0; + struct domain *d = current->domain; + struct vcpu *v; + + if ( (v = domain_vcpu(d, vcpuid)) == NULL ) + return -ENOENT; switch ( cmd ) { @@ -1544,7 +1547,7 @@ arch_do_vcpu_op( } default: - rc = -ENOSYS; + rc = common_vcpu_op(cmd, v, arg); break; } diff --git a/xen/arch/x86/x86_64/domain.c b/xen/arch/x86/x86_64/domain.c index c46dccc25a..62fe51ee74 100644 --- a/xen/arch/x86/x86_64/domain.c +++ b/xen/arch/x86/x86_64/domain.c @@ -13,10 +13,14 @@ CHECK_vcpu_get_physid; #undef xen_vcpu_get_physid int -arch_compat_vcpu_op( - int cmd, struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg) +compat_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg) { - int rc = -ENOSYS; + int rc; + struct domain *d = current->domain; + struct vcpu *v; + + if ( (v = domain_vcpu(d, vcpuid)) == NULL ) + return -ENOENT; switch ( cmd ) { @@ -55,7 +59,11 @@ arch_compat_vcpu_op( } case VCPUOP_get_physid: - rc = arch_do_vcpu_op(cmd, v, arg); + rc = do_vcpu_op(cmd, vcpuid, arg); + break; + + default: + rc = compat_common_vcpu_op(cmd, v, arg); break; } diff --git a/xen/common/compat/domain.c b/xen/common/compat/domain.c index 98b8c15cea..1119534679 100644 --- a/xen/common/compat/domain.c +++ b/xen/common/compat/domain.c @@ -38,14 +38,12 @@ CHECK_vcpu_hvm_context; #endif -int compat_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg) +int compat_common_vcpu_op(int cmd, struct vcpu *v, + XEN_GUEST_HANDLE_PARAM(void) arg) { - struct domain *d = current->domain; - struct vcpu *v; int rc = 0; - - if ( (v = domain_vcpu(d, vcpuid)) == NULL ) - return -ENOENT; + struct domain *d = current->domain; + unsigned int vcpuid = v->vcpu_id; switch ( cmd ) { @@ -102,7 +100,7 @@ int compat_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) ar case VCPUOP_stop_singleshot_timer: case VCPUOP_register_vcpu_info: case VCPUOP_send_nmi: - rc = do_vcpu_op(cmd, vcpuid, arg); + rc = common_vcpu_op(cmd, v, arg); break; case VCPUOP_get_runstate_info: @@ -133,7 +131,7 @@ int compat_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) ar } default: - rc = arch_compat_vcpu_op(cmd, v, arg); + rc = -ENOSYS; break; } diff --git a/xen/common/domain.c b/xen/common/domain.c index 8b53c49d1e..8eb36fe714 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -1559,14 +1559,11 @@ int default_initialise_vcpu(struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg) return rc; } -long do_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg) +long common_vcpu_op(int cmd, struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg) { - struct domain *d = current->domain; - struct vcpu *v; long rc = 0; - - if ( (v = domain_vcpu(d, vcpuid)) == NULL ) - return -ENOENT; + struct domain *d = current->domain; + unsigned int vcpuid = v->vcpu_id; switch ( cmd ) { @@ -1736,7 +1733,7 @@ long do_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg) } default: - rc = arch_do_vcpu_op(cmd, v, arg); + rc = -ENOSYS; break; } diff --git a/xen/include/asm-arm/hypercall.h b/xen/include/asm-arm/hypercall.h index a0c5a31a2f..9fd13c6b2c 100644 --- a/xen/include/asm-arm/hypercall.h +++ b/xen/include/asm-arm/hypercall.h @@ -4,8 +4,6 @@ #include /* for arch_do_domctl */ int do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg); -long do_arm_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg); - long subarch_do_domctl(struct xen_domctl *domctl, struct domain *d, XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl); diff --git a/xen/include/asm-x86/hypercall.h b/xen/include/asm-x86/hypercall.h index 5d394d4923..e614f7c78c 100644 --- a/xen/include/asm-x86/hypercall.h +++ b/xen/include/asm-x86/hypercall.h @@ -152,7 +152,7 @@ compat_physdev_op( XEN_GUEST_HANDLE_PARAM(void) arg); extern int -arch_compat_vcpu_op( +compat_common_vcpu_op( int cmd, struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg); extern int compat_mmuext_op( diff --git a/xen/include/xen/hypercall.h b/xen/include/xen/hypercall.h index 07b10ec230..30558d3c61 100644 --- a/xen/include/xen/hypercall.h +++ b/xen/include/xen/hypercall.h @@ -110,7 +110,7 @@ do_vcpu_op( struct vcpu; extern long -arch_do_vcpu_op(int cmd, +common_vcpu_op(int cmd, struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg); -- 2.26.2