Received: by 10.192.165.156 with SMTP id m28csp570506imm; Mon, 16 Apr 2018 05:23:17 -0700 (PDT) X-Google-Smtp-Source: AIpwx48daLOf9Tr2pBxAVOINZznShCWzjLYW/ecq1hF6/kHQk4fEXdcLLn2YC5pPXN7350ST5LiK X-Received: by 2002:a17:902:3f83:: with SMTP id a3-v6mr15338628pld.279.1523881397589; Mon, 16 Apr 2018 05:23:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523881397; cv=none; d=google.com; s=arc-20160816; b=VxQd+BLNjlbw7FDKZn/8JTBgZEEPMWzACZjVcvExwwRHFgIfyk9t/L1yTfxe914iTA qPmsMme7yQUkNL00zBSr2CYWqBSRqG1tJtdg11O39ckAhNtDWpsxyXte9RgKfY1Fw4RA FGl61M4rvYuxrPiBH+wWzQtmpPbcllrelos4SAOxKm1lxCs5hKuys4voRr3QYtqJwDs9 IJsTKjY8TQ2O7g1UbGuUKYa1Xn/872fE8Ro2B+v0xKcSBzSCex6oJMb+UxH2KhGES4Ds GKlezGYbY/uDBHxs8llZMeYkcza8VceEzoBZjEHFF0VbBwul/XbXAuFx11FzGL84PlkS yb1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=r5O3OUHeqMrIB45rP/yFT7lb+dZngREBuPjbBD1P80Q=; b=g7LqFmya4sOJOq21TKozRXJZ6Xz3zjJw601z9qw+xFvOH1k5cGqvLMV2K0xRZIHG6e F4Bg79vE8CsfWBxg6VbVv3FEe57dTlRi+f5WCkSuHtTiktcmEDzdIdg+neAKMEgLfmDw CUmpr7asoAzi8wT+H+a63eHXkh/T8jzu9vdHvsqXurV2xnHCWk5f/sfIAht7oE319ikf 0Qh0SbSnaENaJUwKMv75ij/CObchlJAvZviGykPLCf+J0iWfOxIY7jVH0iep9d9pkUhc L3Bm6CUKBuMzeFHMZH0KQUj7aKmj490y6/mMg1XscScO4RGpDMjWv7LJAv6UHAgA/41I KZHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g16si10872179pfd.93.2018.04.16.05.23.02; Mon, 16 Apr 2018 05:23:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753704AbeDPLIT (ORCPT + 99 others); Mon, 16 Apr 2018 07:08:19 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45912 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752725AbeDPLIQ (ORCPT ); Mon, 16 Apr 2018 07:08:16 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9862681A88A1; Mon, 16 Apr 2018 11:08:15 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.43.2.155]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA73C111DCF1; Mon, 16 Apr 2018 11:08:13 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org Cc: x86@kernel.org, Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Roman Kagan , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , "Michael Kelley (EOSG)" , Mohammed Gamal , Cathy Avery , linux-kernel@vger.kernel.org Subject: [PATCH v3 3/6] KVM: x86: hyperv: do rep check for each hypercall separately Date: Mon, 16 Apr 2018 13:08:03 +0200 Message-Id: <20180416110806.4896-4-vkuznets@redhat.com> In-Reply-To: <20180416110806.4896-1-vkuznets@redhat.com> References: <20180416110806.4896-1-vkuznets@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 16 Apr 2018 11:08:15 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 16 Apr 2018 11:08:15 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'vkuznets@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Prepare to support TLB flush hypercalls, some of which are REP hypercalls. Also, return HV_STATUS_INVALID_HYPERCALL_INPUT as it seems more appropriate. Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/hyperv.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index 3cb3bb68db7e..67788d358200 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -1309,7 +1309,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu) { u64 param, ingpa, outgpa, ret = HV_STATUS_SUCCESS; uint16_t code, rep_idx, rep_cnt; - bool fast, longmode; + bool fast, longmode, rep; /* * hypercall generates UD from non zero cpl and real mode @@ -1342,28 +1342,31 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu) fast = !!(param & HV_HYPERCALL_FAST_BIT); rep_cnt = (param >> HV_HYPERCALL_REP_COMP_OFFSET) & 0xfff; rep_idx = (param >> HV_HYPERCALL_REP_START_OFFSET) & 0xfff; + rep = !!(rep_cnt || rep_idx); trace_kvm_hv_hypercall(code, fast, rep_cnt, rep_idx, ingpa, outgpa); - /* Hypercall continuation is not supported yet */ - if (rep_cnt || rep_idx) { - ret = HV_STATUS_INVALID_HYPERCALL_CODE; - goto set_result; - } - switch (code) { case HVCALL_NOTIFY_LONG_SPIN_WAIT: + if (unlikely(rep)) { + ret = HV_STATUS_INVALID_HYPERCALL_INPUT; + break; + } kvm_vcpu_on_spin(vcpu, true); break; case HVCALL_SIGNAL_EVENT: + if (unlikely(rep)) { + ret = HV_STATUS_INVALID_HYPERCALL_INPUT; + break; + } ret = kvm_hvcall_signal_event(vcpu, fast, ingpa); if (ret != HV_STATUS_INVALID_PORT_ID) break; /* maybe userspace knows this conn_id: fall through */ case HVCALL_POST_MESSAGE: /* don't bother userspace if it has no way to handle it */ - if (!vcpu_to_synic(vcpu)->active) { - ret = HV_STATUS_INVALID_HYPERCALL_CODE; + if (unlikely(rep || !vcpu_to_synic(vcpu)->active)) { + ret = HV_STATUS_INVALID_HYPERCALL_INPUT; break; } vcpu->run->exit_reason = KVM_EXIT_HYPERV; -- 2.14.3