From patchwork Mon Dec 12 18:37:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vipin Sharma X-Patchwork-Id: 32497 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2402557wrr; Mon, 12 Dec 2022 10:39:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Tb5GqEkETLPxtPJRdsOexZgGSauPfN2uyDSeAET1VqTPq5RIDe1RTtux3MXpp4ECNqxIe X-Received: by 2002:a05:6402:1d8c:b0:46c:c16b:b4c9 with SMTP id dk12-20020a0564021d8c00b0046cc16bb4c9mr15521012edb.7.1670870346245; Mon, 12 Dec 2022 10:39:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670870346; cv=none; d=google.com; s=arc-20160816; b=BMzWYnT74EQGGc5lqgsp27lapFgWdjvMEcz50j/sL6ZJJWnKkiIeEKrFp59NCsbGvs jpEiH3Y0EhNHcsaNn48s5Of7ID1Ov7dPFmZ8PGLQiF56Obvr6S0zjFbqC6nUNEoqorzO +qkRhTs86FWIe5YbtRHKBfRcAy39lttJsSM0Xsv3N5MI/FW0huAYTrlAFxtwNx9akxfh bUmEtbswJVrGIQ90WsUiunU92bMz3UFPF0Msz/TvUSUweU6djv2wvFO5KnJTLwk29y6F TUKw4Bo617MLcRuA5quFiyH+ZCH9eKV8lKkKEMqhSJ+Qe89+6fHKWWmK5pMAtkCu3dbE jsWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=vf/4eKFN2BbTxHb9vSu7n9IRkdIgNgMrNUGeFPcCE4E=; b=QymiClHEPOw3QM06S3QQTz8MtXBD3bza4+OwtpCQLd77Eyu5og0jYuDyWJvWKx494s DuIyI7DcFSjjWxSGpDkvdFj5e9hAKKwZDszA5g/SQsCLWS3+IQa9YOeI1JOttdrccfH4 dEJCsRly1zS3PUWtgMB+r8OY9KHIToY42WWOpWMpqib7XHq/X2nTrNbqC41fA+Z+140+ zWEZUq2eiAF6ddYndeOWvSVp9zxYlOiX2jBXzR6aADtOEjNOtrgzzDHy6j2Bbf+LcMp+ xjjvkXbPK6cMBukdS9yFZ/or6XH9w/oCWzQ/hWOPIRJGzpylWo+XOotYBMmkGUMnHzWz ygDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=BLucr3TO; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cy23-20020a0564021c9700b0046aa7121b8csi7184777edb.232.2022.12.12.10.38.43; Mon, 12 Dec 2022 10:39:06 -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=@google.com header.s=20210112 header.b=BLucr3TO; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233698AbiLLSiU (ORCPT + 99 others); Mon, 12 Dec 2022 13:38:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233562AbiLLShj (ORCPT ); Mon, 12 Dec 2022 13:37:39 -0500 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0621213E21 for ; Mon, 12 Dec 2022 10:37:37 -0800 (PST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-3ceb4c331faso139915047b3.2 for ; Mon, 12 Dec 2022 10:37:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=vf/4eKFN2BbTxHb9vSu7n9IRkdIgNgMrNUGeFPcCE4E=; b=BLucr3TOr4Bc81H7R2ZUt5urqtyzKGHpHVmCLY3m5X8tCgclyt7rcfkYgPpZKVyhDI ccWWN5ADIFdK/w4cH9XNqcJYyQSbbzzcjhP/o+UoDov7EtvOasfnQhOspHFDk19FqsJQ rAX+tZe/9NBgVMPYwg+WQhMhadIBmZxsovpzHXT3OpQa9UfgjviRGMeIjtWiifN3P7OP 6JwROifeI4hBy9qxiZdbku/6HsGFZewkr32tdt6KTThRUrFeXi6nAgV/kIlbi3ZSZn37 CP47IoogJE3psblBjwdEBahqr7ipUpKAMvE6Ah+b5wEj5gPVqDdAVqRFMyh4uraC5cc6 gQ4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vf/4eKFN2BbTxHb9vSu7n9IRkdIgNgMrNUGeFPcCE4E=; b=lbhkIIhtqeXlscGmTd5QMUoqifQqOtyKDLBQA/Za31nUK4iq2e0NpCPJ4XX4VVVw1q ydY8Ta/wiUi2b2SfJ72+cv1I7BXVkFl5llRqSbn7sSGQHFHSSiXnoSQNxVulD1u4HGJd WPLiF54qAoYY4iEnwW6DtqZF6RfT9V+271LSnLgw95xQX78apkYlHY9DPsyiDq1uC03J Tl9JVyaiH7BvepUPMr0Fwt6Q+hF23VWK0W/wXjVstU+t9KwplK1owLA2PxIJg+7YuTxn 5o2qvZAP9iQSFJBWhMYVIOYBUy2altLmIfk4bwtZSzK+rCZnIWqQGPJD7CmWt2YvKTXe o0pA== X-Gm-Message-State: ANoB5plhsI1Q0a578CFOZQtChSWmL3C5xEiJn2sofXLuwlZ7E9oyJYvs hi7E0kBb3faxBVMnaLBrdGvkXJmskCGO X-Received: from vipin.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:479f]) (user=vipinsh job=sendgmr) by 2002:a05:6902:91b:b0:6dd:313b:9b30 with SMTP id bu27-20020a056902091b00b006dd313b9b30mr95149913ybb.618.1670870257178; Mon, 12 Dec 2022 10:37:37 -0800 (PST) Date: Mon, 12 Dec 2022 10:37:15 -0800 In-Reply-To: <20221212183720.4062037-1-vipinsh@google.com> Mime-Version: 1.0 References: <20221212183720.4062037-1-vipinsh@google.com> X-Mailer: git-send-email 2.39.0.rc1.256.g54fd8350bd-goog Message-ID: <20221212183720.4062037-9-vipinsh@google.com> Subject: [Patch v4 08/13] KVM: x86: hyper-v: Use common code for hypercall userspace exit From: Vipin Sharma To: seanjc@google.com, pbonzini@redhat.com, vkuznets@redhat.com, dmatlack@google.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Vipin Sharma X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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?1752034543918347100?= X-GMAIL-MSGID: =?utf-8?q?1752034543918347100?= Remove duplicate code to exit to userspace for hyper-v hypercalls and use a common place to exit. No functional change intended. Signed-off-by: Vipin Sharma Suggested-by: Sean Christopherson Reviewed-by: Vitaly Kuznetsov --- arch/x86/kvm/hyperv.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index 283b6d179dbe..2eb68533d188 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -2521,14 +2521,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu) ret = HV_STATUS_INVALID_HYPERCALL_INPUT; break; } - vcpu->run->exit_reason = KVM_EXIT_HYPERV; - vcpu->run->hyperv.type = KVM_EXIT_HYPERV_HCALL; - vcpu->run->hyperv.u.hcall.input = hc.param; - vcpu->run->hyperv.u.hcall.params[0] = hc.ingpa; - vcpu->run->hyperv.u.hcall.params[1] = hc.outgpa; - vcpu->arch.complete_userspace_io = - kvm_hv_hypercall_complete_userspace; - return 0; + goto hypercall_userspace_exit; case HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST: if (unlikely(hc.var_cnt)) { ret = HV_STATUS_INVALID_HYPERCALL_INPUT; @@ -2587,14 +2580,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu) ret = HV_STATUS_OPERATION_DENIED; break; } - vcpu->run->exit_reason = KVM_EXIT_HYPERV; - vcpu->run->hyperv.type = KVM_EXIT_HYPERV_HCALL; - vcpu->run->hyperv.u.hcall.input = hc.param; - vcpu->run->hyperv.u.hcall.params[0] = hc.ingpa; - vcpu->run->hyperv.u.hcall.params[1] = hc.outgpa; - vcpu->arch.complete_userspace_io = - kvm_hv_hypercall_complete_userspace; - return 0; + goto hypercall_userspace_exit; } default: ret = HV_STATUS_INVALID_HYPERCALL_CODE; @@ -2603,6 +2589,15 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu) hypercall_complete: return kvm_hv_hypercall_complete(vcpu, ret); + +hypercall_userspace_exit: + vcpu->run->exit_reason = KVM_EXIT_HYPERV; + vcpu->run->hyperv.type = KVM_EXIT_HYPERV_HCALL; + vcpu->run->hyperv.u.hcall.input = hc.param; + vcpu->run->hyperv.u.hcall.params[0] = hc.ingpa; + vcpu->run->hyperv.u.hcall.params[1] = hc.outgpa; + vcpu->arch.complete_userspace_io = kvm_hv_hypercall_complete_userspace; + return 0; } void kvm_hv_init_vm(struct kvm *kvm)