From nobody Fri May 3 01:10:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1607071995; cv=none; d=zohomail.com; s=zohoarc; b=Gktlz+TO5Lu0BRHDbi8IewtvPic1HB39Yx9FBHo2iLmFJTzH9Rn1711m4dSTYons1QySfZk2cT89rnRB27iIfAlcvNrByKuKSzU7zjfPeQquRDhF80PkMC67GEwG1hqDG0M489PzQw4/tXX3QU+o7km32vzVc9x8RsUYJ6X+NMU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607071995; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yaMWoBKVxWVw7Z8qM/NkeD5nD3ZYv/c7zC/niSnkkOE=; b=LfRA9veF3K9RkaqsM2GUknaSXX7tFzRdMkzigtCnS7ZC43h4VW49DXTUz1cp9tgRTSYx16iTF9sIAoQSj4xnqeXhNnb6kFZ8ta7rKf9YC2b8ma9sfoCycem7kMLBBqzfbdtu3T1sBSEK4SRvLOpyybt8Bl8cEi8yPsSmyr+dEo4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 160707199592839.95027590187476; Fri, 4 Dec 2020 00:53:15 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.44154.79179 (Exim 4.92) (envelope-from ) id 1kl6pn-0006Of-CT; Fri, 04 Dec 2020 08:52:59 +0000 Received: by outflank-mailman (output) from mailman id 44154.79179; Fri, 04 Dec 2020 08:52:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6pn-0006OX-9Q; Fri, 04 Dec 2020 08:52:59 +0000 Received: by outflank-mailman (input) for mailman id 44154; Fri, 04 Dec 2020 08:52:58 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6pm-0006O4-M1 for xen-devel@lists.xenproject.org; Fri, 04 Dec 2020 08:52:58 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6pm-00048r-7N; Fri, 04 Dec 2020 08:52:58 +0000 Received: from host86-183-162-145.range86-183.btcentralplus.com ([86.183.162.145] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kl6pl-00081O-VI; Fri, 04 Dec 2020 08:52:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=yaMWoBKVxWVw7Z8qM/NkeD5nD3ZYv/c7zC/niSnkkOE=; b=KshhxBEgHpzYHBUii9lBAMJfY+ uN9Nd35uC5ZdIID9uZDKOL4oZgKvwqYteu6Y8J/99Ivr3tFqgAlVyXiXORzhYbSE19+4UEm03FbU8 vomxFx4HeyWLe7ocO1mnaeUBwj8YP9aFC/0FsZxuKKgbAnyoXZp7yGSOpKmGT0a/+qcM=; From: Paul Durrant To: xen-devel@lists.xenproject.org Cc: Paul Durrant , Wei Liu , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v5 01/11] viridian: don't blindly write to 32-bit registers if 'mode' is invalid Date: Fri, 4 Dec 2020 08:52:45 +0000 Message-Id: <20201204085255.26216-2-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201204085255.26216-1-paul@xen.org> References: <20201204085255.26216-1-paul@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) From: Paul Durrant If hvm_guest_x86_mode() returns something other than 8 or 4 then viridian_hypercall() will return immediately but, on the way out, will write back status as if 'mode' was 4. This patch simply makes it leave the regist= ers alone. NOTE: The formatting of the 'out' label and the switch statement are also adjusted as per CODING_STYLE. Signed-off-by: Paul Durrant --- Cc: Wei Liu Cc: Jan Beulich Cc: Andrew Cooper Cc: "Roger Pau Monn=C3=A9" v5: - Fixed yet another CODING_STYLE violation. v4: - Fixed another CODING_STYLE violation. v2: - New in v2 --- xen/arch/x86/hvm/viridian/viridian.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/hvm/viridian/viridian.c b/xen/arch/x86/hvm/viridi= an/viridian.c index dc7183a54627..3dbb5c2d4cc1 100644 --- a/xen/arch/x86/hvm/viridian/viridian.c +++ b/xen/arch/x86/hvm/viridian/viridian.c @@ -692,13 +692,15 @@ int viridian_hypercall(struct cpu_user_regs *regs) break; } =20 -out: + out: output.result =3D status; - switch (mode) { + switch ( mode ) + { case 8: regs->rax =3D output.raw; break; - default: + + case 4: regs->rdx =3D output.raw >> 32; regs->rax =3D (uint32_t)output.raw; break; --=20 2.20.1 From nobody Fri May 3 01:10:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1607071997; cv=none; d=zohomail.com; s=zohoarc; b=Kzbi/uCixRY7H8FsQgMLABhrAnhnuSFFR9UBOGOIFYzg6MsdjP9sn6rUfrtaW1BTUhGFvXDzuOAOzX4gsE6lPlZYgAvse9K9Km/lkQS3MKO3zrtx/HPLaOqWvfAJps+xVwaJUzqsUYn0RJ0tz1YB1GkCs5NTwu7+dR0BcIqa23U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607071997; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SJu8nQYqeczNSm5Lpps/HMrQmEvc2j8XylWQJGoCW0Q=; b=ge8/lpYq05ZkQx4oUDFpj3FjbVDBi6DDm/QDqqdE4IXV562TxSDrzcjFqRoPEuXFZmQPe4tA5guWZMTtxPrm5mEsLHX8vbh6zuOfVwwcXAphKoQ9HV1E6wgAC88jtjDuPwzI2Sxw9ekzyOvzWYG3jQK/RHoVHhDMHZAgXUhMISI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1607071997227777.3803816175839; Fri, 4 Dec 2020 00:53:17 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.44155.79191 (Exim 4.92) (envelope-from ) id 1kl6po-0006Qu-NB; Fri, 04 Dec 2020 08:53:00 +0000 Received: by outflank-mailman (output) from mailman id 44155.79191; Fri, 04 Dec 2020 08:53:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6po-0006Qh-Jq; Fri, 04 Dec 2020 08:53:00 +0000 Received: by outflank-mailman (input) for mailman id 44155; Fri, 04 Dec 2020 08:52:59 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6pn-0006PO-KK for xen-devel@lists.xenproject.org; Fri, 04 Dec 2020 08:52:59 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6pn-00048x-AB; Fri, 04 Dec 2020 08:52:59 +0000 Received: from host86-183-162-145.range86-183.btcentralplus.com ([86.183.162.145] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kl6pn-00081O-2M; Fri, 04 Dec 2020 08:52:59 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=SJu8nQYqeczNSm5Lpps/HMrQmEvc2j8XylWQJGoCW0Q=; b=PfOwomKPCdL09cX78hLgN57hek WxjqHmFxnF8RyIPs9ho6KA6Kn0MMrfCEEm9QlJ81whWTAp6m2v9DdbDWcmeLrS/aqXsP6PIJTIRYf cey5u4nMq3kJV2tjyoO+IU7O26HZJnNYMBjve5y09fe4a40b72fJYRVfuIRj6ubHHo7w=; From: Paul Durrant To: xen-devel@lists.xenproject.org Cc: Paul Durrant , Wei Liu , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v5 02/11] viridian: move flush hypercall implementation into separate function Date: Fri, 4 Dec 2020 08:52:46 +0000 Message-Id: <20201204085255.26216-3-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201204085255.26216-1-paul@xen.org> References: <20201204085255.26216-1-paul@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) From: Paul Durrant This patch moves the implementation of HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE/L= IST that is currently inline in viridian_hypercall() into a new hvcall_flush() function. The new function returns Xen erro values which are then dealt with appropriately. A return value of -ERESTART translates to viridian_hypercall= () returning HVM_HCALL_preempted. Other return values translate to status codes and viridian_hypercall() returning HVM_HCALL_completed. Currently the only values, other than -ERESTART, returned by hvcall_flush() are 0 (indicating success) or -EINVAL. Signed-off-by: Paul Durrant --- Cc: Wei Liu Cc: Jan Beulich Cc: Andrew Cooper Cc: "Roger Pau Monn=C3=A9" v3: - Adjust prototype of new function --- xen/arch/x86/hvm/viridian/viridian.c | 130 ++++++++++++++++----------- 1 file changed, 78 insertions(+), 52 deletions(-) diff --git a/xen/arch/x86/hvm/viridian/viridian.c b/xen/arch/x86/hvm/viridi= an/viridian.c index 3dbb5c2d4cc1..f0b3ee65e3aa 100644 --- a/xen/arch/x86/hvm/viridian/viridian.c +++ b/xen/arch/x86/hvm/viridian/viridian.c @@ -518,6 +518,69 @@ static bool need_flush(void *ctxt, struct vcpu *v) return vcpu_mask & (1ul << v->vcpu_id); } =20 +union hypercall_input { + uint64_t raw; + struct { + uint16_t call_code; + uint16_t fast:1; + uint16_t rsvd1:15; + uint16_t rep_count:12; + uint16_t rsvd2:4; + uint16_t rep_start:12; + uint16_t rsvd3:4; + }; +}; + +union hypercall_output { + uint64_t raw; + struct { + uint16_t result; + uint16_t rsvd1; + uint32_t rep_complete:12; + uint32_t rsvd2:20; + }; +}; + +static int hvcall_flush(const union hypercall_input *input, + union hypercall_output *output, + paddr_t input_params_gpa, + paddr_t output_params_gpa) +{ + struct { + uint64_t address_space; + uint64_t flags; + uint64_t vcpu_mask; + } input_params; + + /* These hypercalls should never use the fast-call convention. */ + if ( input->fast ) + return -EINVAL; + + /* Get input parameters. */ + if ( hvm_copy_from_guest_phys(&input_params, input_params_gpa, + sizeof(input_params)) !=3D HVMTRANS_okay= ) + return -EINVAL; + + /* + * It is not clear from the spec. if we are supposed to + * include current virtual CPU in the set or not in this case, + * so err on the safe side. + */ + if ( input_params.flags & HV_FLUSH_ALL_PROCESSORS ) + input_params.vcpu_mask =3D ~0ul; + + /* + * A false return means that another vcpu is currently trying + * a similar operation, so back off. + */ + if ( !paging_flush_tlb(need_flush, &input_params.vcpu_mask) ) + return -ERESTART; + + output->rep_complete =3D input->rep_count; + + return 0; +} + int viridian_hypercall(struct cpu_user_regs *regs) { struct vcpu *curr =3D current; @@ -525,29 +588,8 @@ int viridian_hypercall(struct cpu_user_regs *regs) int mode =3D hvm_guest_x86_mode(curr); unsigned long input_params_gpa, output_params_gpa; uint16_t status =3D HV_STATUS_SUCCESS; - - union hypercall_input { - uint64_t raw; - struct { - uint16_t call_code; - uint16_t fast:1; - uint16_t rsvd1:15; - uint16_t rep_count:12; - uint16_t rsvd2:4; - uint16_t rep_start:12; - uint16_t rsvd3:4; - }; - } input; - - union hypercall_output { - uint64_t raw; - struct { - uint16_t result; - uint16_t rsvd1; - uint32_t rep_complete:12; - uint32_t rsvd2:20; - }; - } output =3D { 0 }; + union hypercall_input input; + union hypercall_output output =3D {}; =20 ASSERT(is_viridian_domain(currd)); =20 @@ -580,41 +622,25 @@ int viridian_hypercall(struct cpu_user_regs *regs) case HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE: case HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST: { - struct { - uint64_t address_space; - uint64_t flags; - uint64_t vcpu_mask; - } input_params; + int rc =3D hvcall_flush(&input, &output, input_params_gpa, + output_params_gpa); =20 - /* These hypercalls should never use the fast-call convention. */ - status =3D HV_STATUS_INVALID_PARAMETER; - if ( input.fast ) + switch ( rc ) + { + case 0: break; =20 - /* Get input parameters. */ - if ( hvm_copy_from_guest_phys(&input_params, input_params_gpa, - sizeof(input_params)) !=3D - HVMTRANS_okay ) - break; - - /* - * It is not clear from the spec. if we are supposed to - * include current virtual CPU in the set or not in this case, - * so err on the safe side. - */ - if ( input_params.flags & HV_FLUSH_ALL_PROCESSORS ) - input_params.vcpu_mask =3D ~0ul; - - /* - * A false return means that another vcpu is currently trying - * a similar operation, so back off. - */ - if ( !paging_flush_tlb(need_flush, &input_params.vcpu_mask) ) + case -ERESTART: return HVM_HCALL_preempted; =20 - output.rep_complete =3D input.rep_count; + default: + ASSERT_UNREACHABLE(); + /* Fallthrough */ + case -EINVAL: + status =3D HV_STATUS_INVALID_PARAMETER; + break; + } =20 - status =3D HV_STATUS_SUCCESS; break; } =20 --=20 2.20.1 From nobody Fri May 3 01:10:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1607071999; cv=none; d=zohomail.com; s=zohoarc; b=JNiIuxWsEAFthC2BNtA3paymqygIWGcg7QpZhEOj8qwP/8EZSkS4lYJM/vY8HmvoZTLcWb5L0XvJmTVs9HJMVldtgQt4+6efhFgP13eR87DBNiCURocmpH9lZ6WFl7bxo5C6AoHKsSAFYyYGHeSsS771bee9gXzHuGJ9XpmILq0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607071999; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+0Al/tr4MJNf/ubHYvoVGtFEnTG6Fvjontp4axhb608=; b=lh4/TMrBoiAjbAKSQS/WdqcJQjc4yw7zVo3HOsWz89+gSks3MxWTOO4opgPRzk5t5j2PRyODBfiPOjTdYGkdUAJ1HSCf7WO/AzL1TpzOvi1oUZEg8gKgT0bWVlMAD1Oiy6Y/Ki5HSQW2LVfl7PDH3xnrzCCpu6YsgbpdP/pOvnY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1607071999020584.7491597850201; Fri, 4 Dec 2020 00:53:19 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.44156.79203 (Exim 4.92) (envelope-from ) id 1kl6pr-0006Uh-2W; Fri, 04 Dec 2020 08:53:03 +0000 Received: by outflank-mailman (output) from mailman id 44156.79203; Fri, 04 Dec 2020 08:53:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6pq-0006UX-UL; Fri, 04 Dec 2020 08:53:02 +0000 Received: by outflank-mailman (input) for mailman id 44156; Fri, 04 Dec 2020 08:53:00 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6po-0006R7-P4 for xen-devel@lists.xenproject.org; Fri, 04 Dec 2020 08:53:00 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6po-000494-DL; Fri, 04 Dec 2020 08:53:00 +0000 Received: from host86-183-162-145.range86-183.btcentralplus.com ([86.183.162.145] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kl6po-00081O-5d; Fri, 04 Dec 2020 08:53:00 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=+0Al/tr4MJNf/ubHYvoVGtFEnTG6Fvjontp4axhb608=; b=K+uA/vPlVhnw6B2Cd4n3hb6Ytv LhfyaPwl70xjf38pluqEIy4yYZRLstm11FVEMiNZT6IMfJOFm0pOT31UGSb5RCzPdFJMwq4QV5u95 U0IZDX8TUWb+cgKYsVrN8BzNI2O9WTUOhdNpGbvCq3rN34dAVYfROOXizqVG75ec9rQ4=; From: Paul Durrant To: xen-devel@lists.xenproject.org Cc: Paul Durrant , Wei Liu , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v5 03/11] viridian: move IPI hypercall implementation into separate function Date: Fri, 4 Dec 2020 08:52:47 +0000 Message-Id: <20201204085255.26216-4-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201204085255.26216-1-paul@xen.org> References: <20201204085255.26216-1-paul@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) From: Paul Durrant This patch moves the implementation of HVCALL_SEND_IPI that is currently inline in viridian_hypercall() into a new hvcall_ipi() function. The new function returns Xen errno values similarly to hvcall_flush(). Hence the errno translation code in viridial_hypercall() is generalized, removing the need for the local 'status' variable. NOTE: The formatting of the switch statement at the top of viridial_hypercall() is also adjusted as per CODING_STYLE. Signed-off-by: Paul Durrant --- Cc: Wei Liu Cc: Jan Beulich Cc: Andrew Cooper Cc: "Roger Pau Monn=C3=A9" v3: - Adjust prototype of new function v2: - Different formatting adjustment --- xen/arch/x86/hvm/viridian/viridian.c | 168 ++++++++++++++------------- 1 file changed, 87 insertions(+), 81 deletions(-) diff --git a/xen/arch/x86/hvm/viridian/viridian.c b/xen/arch/x86/hvm/viridi= an/viridian.c index f0b3ee65e3aa..77e90b502c69 100644 --- a/xen/arch/x86/hvm/viridian/viridian.c +++ b/xen/arch/x86/hvm/viridian/viridian.c @@ -581,13 +581,72 @@ static int hvcall_flush(const union hypercall_input *= input, return 0; } =20 +static int hvcall_ipi(const union hypercall_input *input, + union hypercall_output *output, + paddr_t input_params_gpa, + paddr_t output_params_gpa) +{ + struct domain *currd =3D current->domain; + struct vcpu *v; + uint32_t vector; + uint64_t vcpu_mask; + + /* Get input parameters. */ + if ( input->fast ) + { + if ( input_params_gpa >> 32 ) + return -EINVAL; + + vector =3D input_params_gpa; + vcpu_mask =3D output_params_gpa; + } + else + { + struct { + uint32_t vector; + uint8_t target_vtl; + uint8_t reserved_zero[3]; + uint64_t vcpu_mask; + } input_params; + + if ( hvm_copy_from_guest_phys(&input_params, input_params_gpa, + sizeof(input_params)) !=3D HVMTRANS_= okay ) + return -EINVAL; + + if ( input_params.target_vtl || + input_params.reserved_zero[0] || + input_params.reserved_zero[1] || + input_params.reserved_zero[2] ) + return -EINVAL; + + vector =3D input_params.vector; + vcpu_mask =3D input_params.vcpu_mask; + } + + if ( vector < 0x10 || vector > 0xff ) + return -EINVAL; + + for_each_vcpu ( currd, v ) + { + if ( v->vcpu_id >=3D (sizeof(vcpu_mask) * 8) ) + return -EINVAL; + + if ( !(vcpu_mask & (1ul << v->vcpu_id)) ) + continue; + + vlapic_set_irq(vcpu_vlapic(v), vector, 0); + } + + return 0; +} + int viridian_hypercall(struct cpu_user_regs *regs) { struct vcpu *curr =3D current; struct domain *currd =3D curr->domain; int mode =3D hvm_guest_x86_mode(curr); unsigned long input_params_gpa, output_params_gpa; - uint16_t status =3D HV_STATUS_SUCCESS; + int rc =3D 0; union hypercall_input input; union hypercall_output output =3D {}; =20 @@ -600,11 +659,13 @@ int viridian_hypercall(struct cpu_user_regs *regs) input_params_gpa =3D regs->rdx; output_params_gpa =3D regs->r8; break; + case 4: input.raw =3D (regs->rdx << 32) | regs->eax; input_params_gpa =3D (regs->rbx << 32) | regs->ecx; output_params_gpa =3D (regs->rdi << 32) | regs->esi; break; + default: goto out; } @@ -616,92 +677,18 @@ int viridian_hypercall(struct cpu_user_regs *regs) * See section 14.5.1 of the specification. */ do_sched_op(SCHEDOP_yield, guest_handle_from_ptr(NULL, void)); - status =3D HV_STATUS_SUCCESS; break; =20 case HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE: case HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST: - { - int rc =3D hvcall_flush(&input, &output, input_params_gpa, - output_params_gpa); - - switch ( rc ) - { - case 0: - break; - - case -ERESTART: - return HVM_HCALL_preempted; - - default: - ASSERT_UNREACHABLE(); - /* Fallthrough */ - case -EINVAL: - status =3D HV_STATUS_INVALID_PARAMETER; - break; - } - + rc =3D hvcall_flush(&input, &output, input_params_gpa, + output_params_gpa); break; - } =20 case HVCALL_SEND_IPI: - { - struct vcpu *v; - uint32_t vector; - uint64_t vcpu_mask; - - status =3D HV_STATUS_INVALID_PARAMETER; - - /* Get input parameters. */ - if ( input.fast ) - { - if ( input_params_gpa >> 32 ) - break; - - vector =3D input_params_gpa; - vcpu_mask =3D output_params_gpa; - } - else - { - struct { - uint32_t vector; - uint8_t target_vtl; - uint8_t reserved_zero[3]; - uint64_t vcpu_mask; - } input_params; - - if ( hvm_copy_from_guest_phys(&input_params, input_params_gpa, - sizeof(input_params)) !=3D - HVMTRANS_okay ) - break; - - if ( input_params.target_vtl || - input_params.reserved_zero[0] || - input_params.reserved_zero[1] || - input_params.reserved_zero[2] ) - break; - - vector =3D input_params.vector; - vcpu_mask =3D input_params.vcpu_mask; - } - - if ( vector < 0x10 || vector > 0xff ) - break; - - for_each_vcpu ( currd, v ) - { - if ( v->vcpu_id >=3D (sizeof(vcpu_mask) * 8) ) - break; - - if ( !(vcpu_mask & (1ul << v->vcpu_id)) ) - continue; - - vlapic_set_irq(vcpu_vlapic(v), vector, 0); - } - - status =3D HV_STATUS_SUCCESS; + rc =3D hvcall_ipi(&input, &output, input_params_gpa, + output_params_gpa); break; - } =20 default: gprintk(XENLOG_WARNING, "unimplemented hypercall %04x\n", @@ -714,12 +701,31 @@ int viridian_hypercall(struct cpu_user_regs *regs) * Given that return a status of 'invalid code' has not so far * caused any problems it's not worth logging. */ - status =3D HV_STATUS_INVALID_HYPERCALL_CODE; + rc =3D -EOPNOTSUPP; break; } =20 out: - output.result =3D status; + switch ( rc ) + { + case 0: + break; + + case -ERESTART: + return HVM_HCALL_preempted; + + case -EOPNOTSUPP: + output.result =3D HV_STATUS_INVALID_HYPERCALL_CODE; + break; + + default: + ASSERT_UNREACHABLE(); + /* Fallthrough */ + case -EINVAL: + output.result =3D HV_STATUS_INVALID_PARAMETER; + break; + } + switch ( mode ) { case 8: --=20 2.20.1 From nobody Fri May 3 01:10:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1607071999; cv=none; d=zohomail.com; s=zohoarc; b=AwH0qfS0TaIlVktZdBFyzsELZH9GKpiFpzL8RjF80lESBG7M9bjPCsa/eUcgm/ayEr3f0LEpH0z+y7Ke3nYV9rmQy90cimQG7e+5HdiECiKUH/yvWyW9GfRb/0IAHgU+a2MXKBxewweCaP+Luh8Gf/oGXQG198tfcsAO1rOUPXc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607071999; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xFA8GhlwFJSlImmF25Y7tztCCVN+Ec94bI0nrH45fvQ=; b=gehgpmzBV1VUg23IoBnQZ3aT1Dbzah0nDCeZhOc3xCYDiqCSIke2tCOlLLv1vqjN3Udimha9JnLxSJbubc3bM7CgkkXkmB6rZDcExwbjqYVQbV+wkM2CHoN3DS7Z0SjClcBZDL5K4tKmJ3HOFFnYO63cyunG3sewi1lth9sp4yQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1607071999208922.9527904280776; Fri, 4 Dec 2020 00:53:19 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.44157.79211 (Exim 4.92) (envelope-from ) id 1kl6pr-0006Vj-N6; Fri, 04 Dec 2020 08:53:03 +0000 Received: by outflank-mailman (output) from mailman id 44157.79211; Fri, 04 Dec 2020 08:53:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6pr-0006VH-9u; Fri, 04 Dec 2020 08:53:03 +0000 Received: by outflank-mailman (input) for mailman id 44157; Fri, 04 Dec 2020 08:53:01 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6pp-0006TD-PK for xen-devel@lists.xenproject.org; Fri, 04 Dec 2020 08:53:01 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6pp-00049A-H0; Fri, 04 Dec 2020 08:53:01 +0000 Received: from host86-183-162-145.range86-183.btcentralplus.com ([86.183.162.145] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kl6pp-00081O-8w; Fri, 04 Dec 2020 08:53:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=xFA8GhlwFJSlImmF25Y7tztCCVN+Ec94bI0nrH45fvQ=; b=a8/kVosfWPSYwcXD7Cp/TzH/Z5 jjX9ICTEGkx6gD8UXD0QzTvGPhONWD8ZTBW4fqgKgyKAlO7z8bEiseBVEE8I928UaWVdjmj94nOLO cAa3W9RpJ810U88YdC0ztRIDXIiaGSmRK/IyytNos41Oe5HI34nuJMV4jjV5LinE9oeo=; From: Paul Durrant To: xen-devel@lists.xenproject.org Cc: Paul Durrant , Wei Liu , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v5 04/11] viridian: introduce a per-cpu hypercall_vpmask and accessor functions... Date: Fri, 4 Dec 2020 08:52:48 +0000 Message-Id: <20201204085255.26216-5-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201204085255.26216-1-paul@xen.org> References: <20201204085255.26216-1-paul@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) From: Paul Durrant ... and make use of them in hvcall_flush()/need_flush(). Subsequent patches will need to deal with virtual processor masks potential= ly wider than 64 bits. Thus, to avoid using too much stack, this patch introduces global per-cpu virtual processor masks and converts the implementation of hvcall_flush() to use them. Signed-off-by: Paul Durrant --- Cc: Wei Liu Cc: Jan Beulich Cc: Andrew Cooper Cc: "Roger Pau Monn=C3=A9" v2: - Modified vpmask_set() to take a base 'vp' and a 64-bit 'mask', still looping over the mask as bitmap.h does not provide a primitive for copyi= ng one mask into another at an offset - Added ASSERTions to verify that we don't attempt to set or test bits beyond the limit of the map --- xen/arch/x86/hvm/viridian/viridian.c | 58 ++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/hvm/viridian/viridian.c b/xen/arch/x86/hvm/viridi= an/viridian.c index 77e90b502c69..0274c8f2eec1 100644 --- a/xen/arch/x86/hvm/viridian/viridian.c +++ b/xen/arch/x86/hvm/viridian/viridian.c @@ -507,15 +507,59 @@ void viridian_domain_deinit(struct domain *d) XFREE(d->arch.hvm.viridian); } =20 +struct hypercall_vpmask { + DECLARE_BITMAP(mask, HVM_MAX_VCPUS); +}; + +static DEFINE_PER_CPU(struct hypercall_vpmask, hypercall_vpmask); + +static void vpmask_empty(struct hypercall_vpmask *vpmask) +{ + bitmap_zero(vpmask->mask, HVM_MAX_VCPUS); +} + +static void vpmask_set(struct hypercall_vpmask *vpmask, unsigned int vp, + uint64_t mask) +{ + unsigned int count =3D sizeof(mask) * 8; + + while ( count-- ) + { + if ( !mask ) + break; + + if ( mask & 1 ) + { + ASSERT(vp < HVM_MAX_VCPUS); + __set_bit(vp, vpmask->mask); + } + + mask >>=3D 1; + vp++; + } +} + +static void vpmask_fill(struct hypercall_vpmask *vpmask) +{ + bitmap_fill(vpmask->mask, HVM_MAX_VCPUS); +} + +static bool vpmask_test(const struct hypercall_vpmask *vpmask, + unsigned int vp) +{ + ASSERT(vp < HVM_MAX_VCPUS); + return test_bit(vp, vpmask->mask); +} + /* * Windows should not issue the hypercalls requiring this callback in the * case where vcpu_id would exceed the size of the mask. */ static bool need_flush(void *ctxt, struct vcpu *v) { - uint64_t vcpu_mask =3D *(uint64_t *)ctxt; + struct hypercall_vpmask *vpmask =3D ctxt; =20 - return vcpu_mask & (1ul << v->vcpu_id); + return vpmask_test(vpmask, v->vcpu_id); } =20 union hypercall_input { @@ -546,6 +590,7 @@ static int hvcall_flush(const union hypercall_input *in= put, paddr_t input_params_gpa, paddr_t output_params_gpa) { + struct hypercall_vpmask *vpmask =3D &this_cpu(hypercall_vpmask); struct { uint64_t address_space; uint64_t flags; @@ -567,13 +612,18 @@ static int hvcall_flush(const union hypercall_input *= input, * so err on the safe side. */ if ( input_params.flags & HV_FLUSH_ALL_PROCESSORS ) - input_params.vcpu_mask =3D ~0ul; + vpmask_fill(vpmask); + else + { + vpmask_empty(vpmask); + vpmask_set(vpmask, 0, input_params.vcpu_mask); + } =20 /* * A false return means that another vcpu is currently trying * a similar operation, so back off. */ - if ( !paging_flush_tlb(need_flush, &input_params.vcpu_mask) ) + if ( !paging_flush_tlb(need_flush, vpmask) ) return -ERESTART; =20 output->rep_complete =3D input->rep_count; --=20 2.20.1 From nobody Fri May 3 01:10:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1607071998; cv=none; d=zohomail.com; s=zohoarc; b=kF5d5xGkg7tqFdRuDVwcsBsiINh7HJVxKMpBo4YSPeFEX3f0uKdHT0Dk5UtZ0gbIb4RoN3cXtxdACkTTC2WcL0ou4Bp/M5wjM5Xde4DTuOVay3Umyh53FEBYcRzs4TMLavXVAf7HLJqLPcELgZXqGBmSR4hFk0J71yyQc2XLy2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607071998; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VB9C9TJfNJjFaO4TuFClll7Hzlvku7IXdGGyn//ncrE=; b=KSrP22s0xkE4R8ON8wt4fTIsXMCa5fog5K4D7ou5xggYG2ZM5Y2jIefqtssmlc41clE+CRdoQzlfF38Hjv8EAieMHSGnFkIZuTXoiYHxxJZv3JtneMihbtL9M+vg+ojcENRQZVwnQs3LhcXX5Nr55r/tpycg2Jirm27jdJq7cwo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1607071998680430.51810092284086; Fri, 4 Dec 2020 00:53:18 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.44160.79223 (Exim 4.92) (envelope-from ) id 1kl6ps-0006Yf-RD; Fri, 04 Dec 2020 08:53:04 +0000 Received: by outflank-mailman (output) from mailman id 44160.79223; Fri, 04 Dec 2020 08:53:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6ps-0006Xu-7j; Fri, 04 Dec 2020 08:53:04 +0000 Received: by outflank-mailman (input) for mailman id 44160; Fri, 04 Dec 2020 08:53:02 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6pq-0006UL-Qv for xen-devel@lists.xenproject.org; Fri, 04 Dec 2020 08:53:02 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6pq-00049V-KR; Fri, 04 Dec 2020 08:53:02 +0000 Received: from host86-183-162-145.range86-183.btcentralplus.com ([86.183.162.145] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kl6pq-00081O-CE; Fri, 04 Dec 2020 08:53:02 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=VB9C9TJfNJjFaO4TuFClll7Hzlvku7IXdGGyn//ncrE=; b=2wXi7Y0oDqBLVpVfPXP1r0Iyvl bfM1+20z4RznhHEEmQj7mM3OyF5tPgsCDnpai3pEn9rDaP666Sh20GEXBcEfYmZNb87tT1Gn9EzNN A5YsWwYraeRVjAANOTd0pWMljFl9ReSgxU54DP164TM+P2leEc//keUb1axcvkBYT5qs=; From: Paul Durrant To: xen-devel@lists.xenproject.org Cc: Paul Durrant , Wei Liu , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v5 05/11] viridian: use hypercall_vpmask in hvcall_ipi() Date: Fri, 4 Dec 2020 08:52:49 +0000 Message-Id: <20201204085255.26216-6-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201204085255.26216-1-paul@xen.org> References: <20201204085255.26216-1-paul@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) From: Paul Durrant A subsequent patch will need to IPI a mask of virtual processors potentially wider than 64 bits. A previous patch introduced per-cpu hypercall_vpmask to allow hvcall_flush() to deal with such wide masks. This patch modifies the implementation of hvcall_ipi() to make use of the same mask structures, introducing a for_each_vp() macro to facilitate traversing a mask. Signed-off-by: Paul Durrant --- Cc: Wei Liu Cc: Jan Beulich Cc: Andrew Cooper Cc: "Roger Pau Monn=C3=A9" v3: - Couple of extra 'const' qualifiers v2: - Drop the 'vp' loop now that vpmask_set() will do it internally --- xen/arch/x86/hvm/viridian/viridian.c | 44 +++++++++++++++++++++------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/hvm/viridian/viridian.c b/xen/arch/x86/hvm/viridi= an/viridian.c index 0274c8f2eec1..3e2393be4160 100644 --- a/xen/arch/x86/hvm/viridian/viridian.c +++ b/xen/arch/x86/hvm/viridian/viridian.c @@ -551,6 +551,26 @@ static bool vpmask_test(const struct hypercall_vpmask = *vpmask, return test_bit(vp, vpmask->mask); } =20 +static unsigned int vpmask_first(const struct hypercall_vpmask *vpmask) +{ + return find_first_bit(vpmask->mask, HVM_MAX_VCPUS); +} + +static unsigned int vpmask_next(const struct hypercall_vpmask *vpmask, + unsigned int vp) +{ + /* + * If vp + 1 > HVM_MAX_VCPUS then find_next_bit() will return + * HVM_MAX_VCPUS, ensuring the for_each_vp ( ... ) loop terminates. + */ + return find_next_bit(vpmask->mask, HVM_MAX_VCPUS, vp + 1); +} + +#define for_each_vp(vpmask, vp) \ + for ( (vp) =3D vpmask_first(vpmask); \ + (vp) < HVM_MAX_VCPUS; \ + (vp) =3D vpmask_next(vpmask, vp) ) + /* * Windows should not issue the hypercalls requiring this callback in the * case where vcpu_id would exceed the size of the mask. @@ -631,13 +651,21 @@ static int hvcall_flush(const union hypercall_input *= input, return 0; } =20 +static void send_ipi(struct hypercall_vpmask *vpmask, uint8_t vector) +{ + struct domain *currd =3D current->domain; + unsigned int vp; + + for_each_vp ( vpmask, vp ) + vlapic_set_irq(vcpu_vlapic(currd->vcpu[vp]), vector, 0); +} + static int hvcall_ipi(const union hypercall_input *input, union hypercall_output *output, paddr_t input_params_gpa, paddr_t output_params_gpa) { - struct domain *currd =3D current->domain; - struct vcpu *v; + struct hypercall_vpmask *vpmask =3D &this_cpu(hypercall_vpmask); uint32_t vector; uint64_t vcpu_mask; =20 @@ -676,16 +704,10 @@ static int hvcall_ipi(const union hypercall_input *in= put, if ( vector < 0x10 || vector > 0xff ) return -EINVAL; =20 - for_each_vcpu ( currd, v ) - { - if ( v->vcpu_id >=3D (sizeof(vcpu_mask) * 8) ) - return -EINVAL; + vpmask_empty(vpmask); + vpmask_set(vpmask, 0, vcpu_mask); =20 - if ( !(vcpu_mask & (1ul << v->vcpu_id)) ) - continue; - - vlapic_set_irq(vcpu_vlapic(v), vector, 0); - } + send_ipi(vpmask, vector); =20 return 0; } --=20 2.20.1 From nobody Fri May 3 01:10:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1607072000; cv=none; d=zohomail.com; s=zohoarc; b=SCgx2EnZXV/yQ4QYMdHt7mpPKMWWV9igTI2VKP/GxP2cuuXLA9GWc6yenMy1TUk45Es+CaGP5kV5qip4HCGKJUcSW7ArPOY54fbwSW6FD1CqIwiQk7POJk4IZcpiF5TXyk1A4U9hZOMgG/JOFSsZj2HiyPeNnZ/N/9tBke5s1jg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607072000; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=e7E0uPlbvldsr+/Or2Usn28nGFXQXE0Lw/3OzuAS844=; b=JwzFG504V6g/DftAoGOmFf/zJqRg2aaK1B5qSW6VjY0doLP+ZvwyxLQjxyEu1gYBVzXHyORmd/RcwAX1oI8Sz9P+Ifzy0s4dzjEHgrynN+15mjGPWMEuWmNDcT+5z+tPWeloxqSnZ5GRyTDE7LTGqTYUloJZfx+Pz/WRk8TBieE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1607072000282671.85284847078; Fri, 4 Dec 2020 00:53:20 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.44161.79239 (Exim 4.92) (envelope-from ) id 1kl6pu-0006cj-4t; Fri, 04 Dec 2020 08:53:06 +0000 Received: by outflank-mailman (output) from mailman id 44161.79239; Fri, 04 Dec 2020 08:53:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6pu-0006cS-0p; Fri, 04 Dec 2020 08:53:06 +0000 Received: by outflank-mailman (input) for mailman id 44161; Fri, 04 Dec 2020 08:53:04 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6ps-0006XX-0s for xen-devel@lists.xenproject.org; Fri, 04 Dec 2020 08:53:04 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6pr-00049c-N7; Fri, 04 Dec 2020 08:53:03 +0000 Received: from host86-183-162-145.range86-183.btcentralplus.com ([86.183.162.145] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kl6pr-00081O-FS; Fri, 04 Dec 2020 08:53:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=e7E0uPlbvldsr+/Or2Usn28nGFXQXE0Lw/3OzuAS844=; b=OY+ZrhmXvDbIM5anfbTCwyHSQ7 30+17YusEJP4C/9uJmN9sKEkYQJYER1LLIyicVMa7AOrV8qTPZ/tjl1ain7osv5p4sfO3bZndXP3l e3pWnu55uxJfdyhOg+O4cqsT7pM7MSEX42tZ32I4OshPooYduemELvob5fG99ldXLvMA=; From: Paul Durrant To: xen-devel@lists.xenproject.org Cc: Paul Durrant , Jan Beulich , Wei Liu , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v5 06/11] viridian: use softirq batching in hvcall_ipi() Date: Fri, 4 Dec 2020 08:52:50 +0000 Message-Id: <20201204085255.26216-7-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201204085255.26216-1-paul@xen.org> References: <20201204085255.26216-1-paul@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) From: Paul Durrant vlapic_ipi() uses a softirq batching mechanism to improve the efficiency of sending a IPIs to large number of processors. This patch modifies send_ipi() (the worker function called by hvcall_ipi()) to also make use of the mechanism when there multiple bits set the hypercall_vpmask. Signed-off-by: Paul Durrant Reviewed-by: Jan Beulich --- Cc: Wei Liu Cc: Andrew Cooper Cc: "Roger Pau Monn=C3=A9" v2: - Don't add the 'nr' field to struct hypercall_vpmask and use bitmap_weight() instead --- xen/arch/x86/hvm/viridian/viridian.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/xen/arch/x86/hvm/viridian/viridian.c b/xen/arch/x86/hvm/viridi= an/viridian.c index 3e2393be4160..894946abcb72 100644 --- a/xen/arch/x86/hvm/viridian/viridian.c +++ b/xen/arch/x86/hvm/viridian/viridian.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -571,6 +572,11 @@ static unsigned int vpmask_next(const struct hypercall= _vpmask *vpmask, (vp) < HVM_MAX_VCPUS; \ (vp) =3D vpmask_next(vpmask, vp) ) =20 +static unsigned int vpmask_nr(const struct hypercall_vpmask *vpmask) +{ + return bitmap_weight(vpmask->mask, HVM_MAX_VCPUS); +} + /* * Windows should not issue the hypercalls requiring this callback in the * case where vcpu_id would exceed the size of the mask. @@ -654,10 +660,17 @@ static int hvcall_flush(const union hypercall_input *= input, static void send_ipi(struct hypercall_vpmask *vpmask, uint8_t vector) { struct domain *currd =3D current->domain; + unsigned int nr =3D vpmask_nr(vpmask); unsigned int vp; =20 + if ( nr > 1 ) + cpu_raise_softirq_batch_begin(); + for_each_vp ( vpmask, vp ) vlapic_set_irq(vcpu_vlapic(currd->vcpu[vp]), vector, 0); + + if ( nr > 1 ) + cpu_raise_softirq_batch_finish(); } =20 static int hvcall_ipi(const union hypercall_input *input, --=20 2.20.1 From nobody Fri May 3 01:10:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1607072002; cv=none; d=zohomail.com; s=zohoarc; b=eCXXCMAhcoN44dddSKe8g3ZDdZWZQxUt03Z1DBX8ZaoKZaE8POhk958n7gm1Ano5lmLKSiUHp0iKxLZOssiBOYiezX2ZQ9eRvut43GN8gwAZ0Y8GM4HXihE4BE12CVoMLFxJHXpbw0Tj++1plO9ZhWSaMFqAsyKF7hZ6tP17vMo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607072002; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nl4mRHTd0JXoiq37UlZWoIYiBW8BoLkrX+JaJVuep5E=; b=IYpD6nf9gcLixf+RP5NUGJHWhaNVmMN6P8cdvAiVvajyd4bwIQr5PhxZu18Yp1YWo2BSHCQBuMxLgZbpRz+LLgryVoRNjn6dajmmq6/aiNb9xKLQ9oHNM5yOCDMgrbkXNpLZXoNMNHXToRy0icn19684epyGa8BliOjVAEwyhCk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1607072002935890.0289095024574; Fri, 4 Dec 2020 00:53:22 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.44162.79244 (Exim 4.92) (envelope-from ) id 1kl6pu-0006eW-VW; Fri, 04 Dec 2020 08:53:06 +0000 Received: by outflank-mailman (output) from mailman id 44162.79244; Fri, 04 Dec 2020 08:53:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6pu-0006e4-JC; Fri, 04 Dec 2020 08:53:06 +0000 Received: by outflank-mailman (input) for mailman id 44162; Fri, 04 Dec 2020 08:53:05 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6pt-0006aE-4g for xen-devel@lists.xenproject.org; Fri, 04 Dec 2020 08:53:05 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6ps-00049j-R8; Fri, 04 Dec 2020 08:53:04 +0000 Received: from host86-183-162-145.range86-183.btcentralplus.com ([86.183.162.145] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kl6ps-00081O-If; Fri, 04 Dec 2020 08:53:04 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=nl4mRHTd0JXoiq37UlZWoIYiBW8BoLkrX+JaJVuep5E=; b=6zsb+ZVoAijkIwEnP9g+Ejy13w PKwIucOQbBygvPQpn5yX8E0ZgU85N4+jHLceINxz9jCj3Dg7m/ckxe5TWbqkyM9psliQvV/sh9Drb IpeVpe7EsB4cFv7Q/pX0v7dnYW6OFhgiuqT4eMP3f9SpSqzJH3pRUUcIcgQMVUVcSELo=; From: Paul Durrant To: xen-devel@lists.xenproject.org Cc: Paul Durrant , Wei Liu , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v5 07/11] viridian: add ExProcessorMasks variants of the flush hypercalls Date: Fri, 4 Dec 2020 08:52:51 +0000 Message-Id: <20201204085255.26216-8-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201204085255.26216-1-paul@xen.org> References: <20201204085255.26216-1-paul@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) From: Paul Durrant The Microsoft Hypervisor TLFS specifies variants of the already implemented HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE/LIST hypercalls that take a 'Virtual Processor Set' as an argument rather than a simple 64-bit mask. This patch adds a new hvcall_flush_ex() function to implement these (HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE/LIST_EX) hypercalls. This makes use of new helper functions, hv_vpset_nr_banks() and hv_vpset_to_vpmask(), to determine the size of the Virtual Processor Set (so it can be copied from guest memory) and parse it into hypercall_vpmask (respectively). NOTE: A guest should not yet issue these hypercalls as 'ExProcessorMasks' support needs to be advertised via CPUID. This will be done in a subsequent patch. Signed-off-by: Paul Durrant --- Cc: Wei Liu Cc: Jan Beulich Cc: Andrew Cooper Cc: "Roger Pau Monn=C3=A9" v3: - Adjust one of the helper macros - A few more consts and type tweaks - Adjust prototype of new function v2: - Add helper macros to define mask and struct sizes - Use a union to determine the size of 'hypercall_vpset' - Use hweight64() in hv_vpset_nr_banks() - Sanity check size before hvm_copy_from_guest_phys() --- xen/arch/x86/hvm/viridian/viridian.c | 141 +++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) diff --git a/xen/arch/x86/hvm/viridian/viridian.c b/xen/arch/x86/hvm/viridi= an/viridian.c index 894946abcb72..a4cece722e97 100644 --- a/xen/arch/x86/hvm/viridian/viridian.c +++ b/xen/arch/x86/hvm/viridian/viridian.c @@ -577,6 +577,69 @@ static unsigned int vpmask_nr(const struct hypercall_v= pmask *vpmask) return bitmap_weight(vpmask->mask, HVM_MAX_VCPUS); } =20 +#define HV_VPSET_BANK_SIZE \ + sizeof_field(struct hv_vpset, bank_contents[0]) + +#define HV_VPSET_SIZE(banks) \ + (offsetof(struct hv_vpset, bank_contents) + \ + ((banks) * HV_VPSET_BANK_SIZE)) + +#define HV_VPSET_MAX_BANKS \ + (sizeof_field(struct hv_vpset, valid_bank_mask) * 8) + +union hypercall_vpset { + struct hv_vpset set; + uint8_t pad[HV_VPSET_SIZE(HV_VPSET_MAX_BANKS)]; +}; + +static DEFINE_PER_CPU(union hypercall_vpset, hypercall_vpset); + +static unsigned int hv_vpset_nr_banks(struct hv_vpset *vpset) +{ + return hweight64(vpset->valid_bank_mask); +} + +static uint16_t hv_vpset_to_vpmask(const struct hv_vpset *set, + struct hypercall_vpmask *vpmask) +{ +#define NR_VPS_PER_BANK (HV_VPSET_BANK_SIZE * 8) + + switch ( set->format ) + { + case HV_GENERIC_SET_ALL: + vpmask_fill(vpmask); + return 0; + + case HV_GENERIC_SET_SPARSE_4K: + { + uint64_t bank_mask; + unsigned int vp, bank =3D 0; + + vpmask_empty(vpmask); + for ( vp =3D 0, bank_mask =3D set->valid_bank_mask; + bank_mask; + vp +=3D NR_VPS_PER_BANK, bank_mask >>=3D 1 ) + { + if ( bank_mask & 1 ) + { + uint64_t mask =3D set->bank_contents[bank]; + + vpmask_set(vpmask, vp, mask); + bank++; + } + } + return 0; + } + + default: + break; + } + + return -EINVAL; + +#undef NR_VPS_PER_BANK +} + /* * Windows should not issue the hypercalls requiring this callback in the * case where vcpu_id would exceed the size of the mask. @@ -657,6 +720,78 @@ static int hvcall_flush(const union hypercall_input *i= nput, return 0; } =20 +static int hvcall_flush_ex(const union hypercall_input *input, + union hypercall_output *output, + paddr_t input_params_gpa, + paddr_t output_params_gpa) +{ + struct hypercall_vpmask *vpmask =3D &this_cpu(hypercall_vpmask); + struct { + uint64_t address_space; + uint64_t flags; + struct hv_vpset set; + } input_params; + + /* These hypercalls should never use the fast-call convention. */ + if ( input->fast ) + return -EINVAL; + + /* Get input parameters. */ + if ( hvm_copy_from_guest_phys(&input_params, input_params_gpa, + sizeof(input_params)) !=3D HVMTRANS_okay= ) + return -EINVAL; + + if ( input_params.flags & HV_FLUSH_ALL_PROCESSORS ) + vpmask_fill(vpmask); + else + { + union hypercall_vpset *vpset =3D &this_cpu(hypercall_vpset); + struct hv_vpset *set =3D &vpset->set; + size_t size; + int rc; + + *set =3D input_params.set; + if ( set->format =3D=3D HV_GENERIC_SET_SPARSE_4K ) + { + unsigned long offset =3D offsetof(typeof(input_params), + set.bank_contents); + + size =3D sizeof(*set->bank_contents) * hv_vpset_nr_banks(set); + + if ( offsetof(typeof(*vpset), set.bank_contents[0]) + size > + sizeof(*vpset) ) + { + ASSERT_UNREACHABLE(); + return -EINVAL; + } + + if ( hvm_copy_from_guest_phys(&set->bank_contents[0], + input_params_gpa + offset, + size) !=3D HVMTRANS_okay) + return -EINVAL; + + size +=3D sizeof(*set); + } + else + size =3D sizeof(*set); + + rc =3D hv_vpset_to_vpmask(set, vpmask); + if ( rc ) + return rc; + } + + /* + * A false return means that another vcpu is currently trying + * a similar operation, so back off. + */ + if ( !paging_flush_tlb(need_flush, vpmask) ) + return -ERESTART; + + output->rep_complete =3D input->rep_count; + + return 0; +} + static void send_ipi(struct hypercall_vpmask *vpmask, uint8_t vector) { struct domain *currd =3D current->domain; @@ -770,6 +905,12 @@ int viridian_hypercall(struct cpu_user_regs *regs) output_params_gpa); break; =20 + case HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX: + case HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST_EX: + rc =3D hvcall_flush_ex(&input, &output, input_params_gpa, + output_params_gpa); + break; + case HVCALL_SEND_IPI: rc =3D hvcall_ipi(&input, &output, input_params_gpa, output_params_gpa); --=20 2.20.1 From nobody Fri May 3 01:10:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1607072004; cv=none; d=zohomail.com; s=zohoarc; b=ayLlJ1ZFHzEwWWKMnXN9mPGS+cEjg9zdYX+qht8JpdLGLNmSJ74ipl5i1ZqANPFhBhCDDyFva6bYoceGd/XlONOhf2VIWxbtLZRWhNZ+Db2g0T3Y0RswaW76WEc8JUM7vIKPE62wjDXY0tAmraete7npMu+i1S9rGQFBWKbIDLI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607072004; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=H830RGebjhB/7fuISXxF2D6b2V+2uO+On0a8uMTm7KY=; b=UfwNFKXCbE0Q2olRRP5+F1hff5stDkytEwWYmRN3ZJhrjZtDzGXMIVAwXBhZgy62ZBSD6BKUtdNVZY4cC3yEEzGxXWngGuB7gj95sAl+z/hjZumeHVfwVy836qPIs2WYScjKmnEjMqaeXTh7kvZcJzH5BJzVK+eqqhNSRYCw+Jw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 16070720047755.9936505883907785; Fri, 4 Dec 2020 00:53:24 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.44163.79262 (Exim 4.92) (envelope-from ) id 1kl6pw-0006jN-Mv; Fri, 04 Dec 2020 08:53:08 +0000 Received: by outflank-mailman (output) from mailman id 44163.79262; Fri, 04 Dec 2020 08:53:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6pw-0006io-Aw; Fri, 04 Dec 2020 08:53:08 +0000 Received: by outflank-mailman (input) for mailman id 44163; Fri, 04 Dec 2020 08:53:06 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6pu-0006dA-9S for xen-devel@lists.xenproject.org; Fri, 04 Dec 2020 08:53:06 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6pt-00049r-Te; Fri, 04 Dec 2020 08:53:05 +0000 Received: from host86-183-162-145.range86-183.btcentralplus.com ([86.183.162.145] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kl6pt-00081O-Lr; Fri, 04 Dec 2020 08:53:05 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=H830RGebjhB/7fuISXxF2D6b2V+2uO+On0a8uMTm7KY=; b=eGpiq7b7BXH9eR6zIvn71DZQHO 1Ds1U6gZzv/JldBMDFJ1OZ7n/gGoWqTulXWjBe2T145I+t7/FdaM1xpHmUgJv62AA9jncSVvW4045 huGLDJ4zqG7Voem7xs7L+2hf1veYx8jxUtHgoPRTdbWrIPDQywF8RRMuaIbx7yEKmXoo=; From: Paul Durrant To: xen-devel@lists.xenproject.org Cc: Paul Durrant , Wei Liu , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v5 08/11] viridian: add ExProcessorMasks variant of the IPI hypercall Date: Fri, 4 Dec 2020 08:52:52 +0000 Message-Id: <20201204085255.26216-9-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201204085255.26216-1-paul@xen.org> References: <20201204085255.26216-1-paul@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) From: Paul Durrant A previous patch introduced variants of the flush hypercalls that take a 'Virtual Processor Set' as an argument rather than a simple 64-bit mask. This patch introduces a similar variant of the HVCALL_SEND_IPI hypercall (HVCALL_SEND_IPI_EX). NOTE: As with HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE/LIST_EX, a guest should not yet issue the HVCALL_SEND_IPI_EX hypercall as support for 'ExProcessorMasks' is not yet advertised via CPUID. Signed-off-by: Paul Durrant --- Cc: Wei Liu Cc: Jan Beulich Cc: Andrew Cooper Cc: "Roger Pau Monn=C3=A9" v3: - Adjust prototype of new function v2: - Sanity check size before hvm_copy_from_guest_phys() --- xen/arch/x86/hvm/viridian/viridian.c | 74 ++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/xen/arch/x86/hvm/viridian/viridian.c b/xen/arch/x86/hvm/viridi= an/viridian.c index a4cece722e97..5e4a2fa53ad4 100644 --- a/xen/arch/x86/hvm/viridian/viridian.c +++ b/xen/arch/x86/hvm/viridian/viridian.c @@ -860,6 +860,75 @@ static int hvcall_ipi(const union hypercall_input *inp= ut, return 0; } =20 +static int hvcall_ipi_ex(const union hypercall_input *input, + union hypercall_output *output, + paddr_t input_params_gpa, + paddr_t output_params_gpa) +{ + struct hypercall_vpmask *vpmask =3D &this_cpu(hypercall_vpmask); + struct { + uint32_t vector; + uint8_t target_vtl; + uint8_t reserved_zero[3]; + struct hv_vpset set; + } input_params; + union hypercall_vpset *vpset =3D &this_cpu(hypercall_vpset); + struct hv_vpset *set =3D &vpset->set; + size_t size; + int rc; + + /* These hypercalls should never use the fast-call convention. */ + if ( input->fast ) + return -EINVAL; + + /* Get input parameters. */ + if ( hvm_copy_from_guest_phys(&input_params, input_params_gpa, + sizeof(input_params)) !=3D HVMTRANS_okay= ) + return -EINVAL; + + if ( input_params.target_vtl || + input_params.reserved_zero[0] || + input_params.reserved_zero[1] || + input_params.reserved_zero[2] ) + return HV_STATUS_INVALID_PARAMETER; + + if ( input_params.vector < 0x10 || input_params.vector > 0xff ) + return HV_STATUS_INVALID_PARAMETER; + + *set =3D input_params.set; + if ( set->format =3D=3D HV_GENERIC_SET_SPARSE_4K ) + { + unsigned long offset =3D offsetof(typeof(input_params), + set.bank_contents); + + size =3D sizeof(*set->bank_contents) * hv_vpset_nr_banks(set); + + if ( offsetof(typeof(*vpset), set.bank_contents[0]) + size > + sizeof(*vpset) ) + { + ASSERT_UNREACHABLE(); + return -EINVAL; + } + + if ( hvm_copy_from_guest_phys(&set->bank_contents, + input_params_gpa + offset, + size) !=3D HVMTRANS_okay) + return -EINVAL; + + size +=3D sizeof(*set); + } + else + size =3D sizeof(*set); + + rc =3D hv_vpset_to_vpmask(set, vpmask); + if ( rc ) + return rc; + + send_ipi(vpmask, input_params.vector); + + return 0; +} + int viridian_hypercall(struct cpu_user_regs *regs) { struct vcpu *curr =3D current; @@ -916,6 +985,11 @@ int viridian_hypercall(struct cpu_user_regs *regs) output_params_gpa); break; =20 + case HVCALL_SEND_IPI_EX: + rc =3D hvcall_ipi_ex(&input, &output, input_params_gpa, + output_params_gpa); + break; + default: gprintk(XENLOG_WARNING, "unimplemented hypercall %04x\n", input.call_code); --=20 2.20.1 From nobody Fri May 3 01:10:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1607072005; cv=none; d=zohomail.com; s=zohoarc; b=lNS4x6H5tK9qbVruGoy2uq7IpKnuPMTRdrTDmS97zx5w2j/y25gNLEB1tq8q41oXNO7tUKwlzBs1CwJl709Ui+A9litGB2chbPqIJWc9UXQynmM9IJ85zSBXk0eoaN7KOqVuWK+0A0Y8ltQNw4r4NhRs5LBH1HFEgD1VFRzvBCU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607072005; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hKsDOrpgiJSDA+ammFrF07gmisbXWrRCPKTZaRZM/PU=; b=lB0I8S5wUZJ0z9LT6PIchOcqyvFTJq0h+d/0SJhumMXU70e3Ji5DEtoWgN3iVEaF+ztt7hsXUEJEDqNOd+Il/BDQ2upbik5LBXW0wlQgvVW/pInZI4M/4/hqd5lQlzls4w8qMQB9sfbJ3fWiR7grexTK7X3G83NRIR0uLFtWczc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1607072005400339.3719531113843; Fri, 4 Dec 2020 00:53:25 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.44164.79270 (Exim 4.92) (envelope-from ) id 1kl6px-0006lp-LS; Fri, 04 Dec 2020 08:53:09 +0000 Received: by outflank-mailman (output) from mailman id 44164.79270; Fri, 04 Dec 2020 08:53:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6px-0006ku-3R; Fri, 04 Dec 2020 08:53:09 +0000 Received: by outflank-mailman (input) for mailman id 44164; Fri, 04 Dec 2020 08:53:07 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6pv-0006fg-5V for xen-devel@lists.xenproject.org; Fri, 04 Dec 2020 08:53:07 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6pv-0004A1-0R; Fri, 04 Dec 2020 08:53:07 +0000 Received: from host86-183-162-145.range86-183.btcentralplus.com ([86.183.162.145] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kl6pu-00081O-P7; Fri, 04 Dec 2020 08:53:06 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=hKsDOrpgiJSDA+ammFrF07gmisbXWrRCPKTZaRZM/PU=; b=PqaHCFE1LPrk7HnD2c1OEv7J/E 0b34JrxmglfSclnRKx86yjDeRwJB4FAzShN68tZWbct3X8oRmNBYKIBHAT38QTmjY25AyiosPP9To LFkh8JGW4U6VmJpxjF2a7/pPEZiunbeFQGxBGb2IoeW9oU2c7Yrx96zge2CR73L5eR9Q=; From: Paul Durrant To: xen-devel@lists.xenproject.org Cc: Paul Durrant , Wei Liu , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v5 09/11] viridian: log initial invocation of each type of hypercall Date: Fri, 4 Dec 2020 08:52:53 +0000 Message-Id: <20201204085255.26216-10-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201204085255.26216-1-paul@xen.org> References: <20201204085255.26216-1-paul@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) From: Paul Durrant To make is simpler to observe which viridian hypercalls are issued by a particular Windows guest, this patch adds a per-domain mask to track them. Each type of hypercall causes a different bit to be set in the mask and when the bit transitions from clear to set, a log line is emitted showing the name of the hypercall and the domain that issued it. Signed-off-by: Paul Durrant --- Cc: Wei Liu Cc: Jan Beulich Cc: Andrew Cooper Cc: "Roger Pau Monn=C3=A9" v2: - Use DECLARE_BITMAP() for 'hypercall_flags' - Use an enum for _HCALL_* values --- xen/arch/x86/hvm/viridian/viridian.c | 21 +++++++++++++++++++++ xen/include/asm-x86/hvm/viridian.h | 10 ++++++++++ 2 files changed, 31 insertions(+) diff --git a/xen/arch/x86/hvm/viridian/viridian.c b/xen/arch/x86/hvm/viridi= an/viridian.c index 5e4a2fa53ad4..efd8e3a900c3 100644 --- a/xen/arch/x86/hvm/viridian/viridian.c +++ b/xen/arch/x86/hvm/viridian/viridian.c @@ -933,6 +933,7 @@ int viridian_hypercall(struct cpu_user_regs *regs) { struct vcpu *curr =3D current; struct domain *currd =3D curr->domain; + struct viridian_domain *vd =3D currd->arch.hvm.viridian; int mode =3D hvm_guest_x86_mode(curr); unsigned long input_params_gpa, output_params_gpa; int rc =3D 0; @@ -962,6 +963,10 @@ int viridian_hypercall(struct cpu_user_regs *regs) switch ( input.call_code ) { case HVCALL_NOTIFY_LONG_SPIN_WAIT: + if ( !test_and_set_bit(_HCALL_spin_wait, vd->hypercall_flags) ) + printk(XENLOG_G_INFO "d%d: VIRIDIAN HVCALL_NOTIFY_LONG_SPIN_WA= IT\n", + currd->domain_id); + /* * See section 14.5.1 of the specification. */ @@ -970,22 +975,38 @@ int viridian_hypercall(struct cpu_user_regs *regs) =20 case HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE: case HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST: + if ( !test_and_set_bit(_HCALL_flush, vd->hypercall_flags) ) + printk(XENLOG_G_INFO "%pd: VIRIDIAN HVCALL_FLUSH_VIRTUAL_ADDRE= SS_SPACE/LIST\n", + currd); + rc =3D hvcall_flush(&input, &output, input_params_gpa, output_params_gpa); break; =20 case HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX: case HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST_EX: + if ( !test_and_set_bit(_HCALL_flush_ex, vd->hypercall_flags) ) + printk(XENLOG_G_INFO "%pd: VIRIDIAN HVCALL_FLUSH_VIRTUAL_ADDRE= SS_SPACE/LIST_EX\n", + currd); + rc =3D hvcall_flush_ex(&input, &output, input_params_gpa, output_params_gpa); break; =20 case HVCALL_SEND_IPI: + if ( !test_and_set_bit(_HCALL_ipi, vd->hypercall_flags) ) + printk(XENLOG_G_INFO "%pd: VIRIDIAN HVCALL_SEND_IPI\n", + currd); + rc =3D hvcall_ipi(&input, &output, input_params_gpa, output_params_gpa); break; =20 case HVCALL_SEND_IPI_EX: + if ( !test_and_set_bit(_HCALL_ipi_ex, vd->hypercall_flags) ) + printk(XENLOG_G_INFO "%pd: VIRIDIAN HVCALL_SEND_IPI_EX\n", + currd); + rc =3D hvcall_ipi_ex(&input, &output, input_params_gpa, output_params_gpa); break; diff --git a/xen/include/asm-x86/hvm/viridian.h b/xen/include/asm-x86/hvm/v= iridian.h index cbf77d9c760b..4c8ff6e80b6f 100644 --- a/xen/include/asm-x86/hvm/viridian.h +++ b/xen/include/asm-x86/hvm/viridian.h @@ -55,10 +55,20 @@ struct viridian_time_ref_count int64_t off; }; =20 +enum { + _HCALL_spin_wait, + _HCALL_flush, + _HCALL_flush_ex, + _HCALL_ipi, + _HCALL_ipi_ex, + _HCALL_nr /* must be last */ +}; + struct viridian_domain { union hv_guest_os_id guest_os_id; union hv_vp_assist_page_msr hypercall_gpa; + DECLARE_BITMAP(hypercall_flags, _HCALL_nr); struct viridian_time_ref_count time_ref_count; struct viridian_page reference_tsc; }; --=20 2.20.1 From nobody Fri May 3 01:10:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1607072464; cv=none; d=zohomail.com; s=zohoarc; b=kjzOseLecSTgK1CKRDBv6f+skPptiHeqvNX5xriH0cMj9YkjP4H8Ckdfd5xkJEQg4T9UtCJzOOGR/c+7tc9SiDrcgY9GyehHChvFhDt1gicOyeojwwDwlUAYtG4TEbMx0IaTHPR1df3KXlBAlYLl5V41v0pueOOPq4fubEosoYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607072464; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=J/9PuceCgCRlAlZXFD/ir5Ro6bbX2Egg10HbABKGdYw=; b=hhOO1Lbmfp3ah/G78bX+ZeHOJOWwK8jFUALGlR/RLokyubRXfteG4BWRwP3jWe36O3ozz5xR2JlGjeVTfzPX3MOAL34RMBTkxSBwfsVHLB5mR6DciFMpVd+v+3UUiAtZzGupRgVi1Wfr0J+RlkfQ8wDdINkvWuJOWKw3P0dVUYk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1607072464508646.8988761321644; Fri, 4 Dec 2020 01:01:04 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.44225.79306 (Exim 4.92) (envelope-from ) id 1kl6xK-00009R-OU; Fri, 04 Dec 2020 09:00:46 +0000 Received: by outflank-mailman (output) from mailman id 44225.79306; Fri, 04 Dec 2020 09:00:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6xK-00009H-HN; Fri, 04 Dec 2020 09:00:46 +0000 Received: by outflank-mailman (input) for mailman id 44225; Fri, 04 Dec 2020 09:00:45 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6xJ-00008k-Mi for xen-devel@lists.xenproject.org; Fri, 04 Dec 2020 09:00:45 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6xI-0004P3-Jy; Fri, 04 Dec 2020 09:00:44 +0000 Received: from host86-183-162-145.range86-183.btcentralplus.com ([86.183.162.145] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kl6pw-00081O-8u; Fri, 04 Dec 2020 08:53:08 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=J/9PuceCgCRlAlZXFD/ir5Ro6bbX2Egg10HbABKGdYw=; b=LI6eqTxBu+gcE3HIy0b4ZdcAot jGhA7w7d1qxEAPeKHblHOYZkxCDcLqW5L7ttFgZQAUD7fKO7Ol+Jm1IHnBjHJnlMhaXltkNXHIOKm Z9mzneCIyDaZWDdMO3DqPNlCkmdbsyYm/B/4PhV7aD1XmZqbXfyG9bjuN/bp9f1cShL8=; From: Paul Durrant To: xen-devel@lists.xenproject.org Cc: Paul Durrant , Wei Liu , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini Subject: [PATCH v5 10/11] viridian: add a new '_HVMPV_ex_processor_masks' bit into HVM_PARAM_VIRIDIAN... Date: Fri, 4 Dec 2020 08:52:54 +0000 Message-Id: <20201204085255.26216-11-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201204085255.26216-1-paul@xen.org> References: <20201204085255.26216-1-paul@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) From: Paul Durrant ... and advertise ExProcessorMasks support if it is set. Support is advertised by setting bit 11 in CPUID:40000004:EAX. Signed-off-by: Paul Durrant --- Cc: Wei Liu Cc: Jan Beulich Cc: Andrew Cooper Cc: "Roger Pau Monn=C3=A9" Cc: George Dunlap Cc: Ian Jackson Cc: Julien Grall Cc: Stefano Stabellini --- xen/arch/x86/hvm/viridian/viridian.c | 3 +++ xen/include/public/hvm/params.h | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/hvm/viridian/viridian.c b/xen/arch/x86/hvm/viridi= an/viridian.c index efd8e3a900c3..ed978047c12f 100644 --- a/xen/arch/x86/hvm/viridian/viridian.c +++ b/xen/arch/x86/hvm/viridian/viridian.c @@ -84,6 +84,7 @@ typedef union _HV_CRASH_CTL_REG_CONTENTS #define CPUID4A_MSR_BASED_APIC (1 << 3) #define CPUID4A_RELAX_TIMER_INT (1 << 5) #define CPUID4A_SYNTHETIC_CLUSTER_IPI (1 << 10) +#define CPUID4A_EX_PROCESSOR_MASKS (1 << 11) =20 /* Viridian CPUID leaf 6: Implementation HW features detected and in use */ #define CPUID6A_APIC_OVERLAY (1 << 0) @@ -197,6 +198,8 @@ void cpuid_viridian_leaves(const struct vcpu *v, uint32= _t leaf, res->a |=3D CPUID4A_MSR_BASED_APIC; if ( viridian_feature_mask(d) & HVMPV_hcall_ipi ) res->a |=3D CPUID4A_SYNTHETIC_CLUSTER_IPI; + if ( viridian_feature_mask(d) & HVMPV_ex_processor_masks ) + res->a |=3D CPUID4A_EX_PROCESSOR_MASKS; =20 /* * This value is the recommended number of attempts to try to diff --git a/xen/include/public/hvm/params.h b/xen/include/public/hvm/param= s.h index 0e3fdca09646..3b0a0f45da53 100644 --- a/xen/include/public/hvm/params.h +++ b/xen/include/public/hvm/params.h @@ -164,6 +164,10 @@ #define _HVMPV_hcall_ipi 9 #define HVMPV_hcall_ipi (1 << _HVMPV_hcall_ipi) =20 +/* Enable ExProcessorMasks */ +#define _HVMPV_ex_processor_masks 10 +#define HVMPV_ex_processor_masks (1 << _HVMPV_ex_processor_masks) + #define HVMPV_feature_mask \ (HVMPV_base_freq | \ HVMPV_no_freq | \ @@ -174,7 +178,8 @@ HVMPV_crash_ctl | \ HVMPV_synic | \ HVMPV_stimer | \ - HVMPV_hcall_ipi) + HVMPV_hcall_ipi | \ + HVMPV_ex_processor_masks) =20 #endif =20 --=20 2.20.1 From nobody Fri May 3 01:10:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1607072464; cv=none; d=zohomail.com; s=zohoarc; b=mDqlzRiBP77og5ezQYa4u210kq0UR5BL3uzDPMflcVu0XCt3Ux33HaPrepsKv1IJRazX6gZmpFxkcNfHlbJk5i85JC9tZ7lhmsUxpmTbhh/AAHIEEYhRoEKf4FngHk746R9yeQ6j+qo/PoRGOOhmjLrfoKoJhi/dQOzbBng1QTY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607072464; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/tzXLkeYgeohzzpZOobPIXPIDOQTKzNBQ+V78872kJQ=; b=Uwz8tSJ7+hIGapOmcC6uaeasj3oSeRgh7vTxjh7KQdu447upt5DWIBk/gHre2HtHU5UaJ8cRJ5DYfjrXv5XYRkngEg6h1190DofrOtnjD4Ve+fwxArKRb9XhR7JTWIMvaAODsm2yCGyU0UJ9B5VtlqXUQW5q04pCT19aIJIeWd0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1607072464346931.8492348554089; Fri, 4 Dec 2020 01:01:04 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.44224.79299 (Exim 4.92) (envelope-from ) id 1kl6xK-00008x-C2; Fri, 04 Dec 2020 09:00:46 +0000 Received: by outflank-mailman (output) from mailman id 44224.79299; Fri, 04 Dec 2020 09:00:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6xK-00008q-8z; Fri, 04 Dec 2020 09:00:46 +0000 Received: by outflank-mailman (input) for mailman id 44224; Fri, 04 Dec 2020 09:00:45 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6xJ-00008L-EN for xen-devel@lists.xenproject.org; Fri, 04 Dec 2020 09:00:45 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kl6xI-0004P1-FC; Fri, 04 Dec 2020 09:00:44 +0000 Received: from host86-183-162-145.range86-183.btcentralplus.com ([86.183.162.145] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kl6px-00081O-8y; Fri, 04 Dec 2020 08:53:09 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=/tzXLkeYgeohzzpZOobPIXPIDOQTKzNBQ+V78872kJQ=; b=ExZOQlzjNsrwe3ex28436t2A3S E1oOtHtTq/eANBuuOGNN5+dEWad/tpCtP1jOZjMx2fyY3+pdAy+Z3UrpTPZTx68kkjp03+qRpEsns r7mere0DVCt5K+uhIJ0C+e+MZqQ/m4X5iGl/89v8tROTKxG/LH//waHC/FTPHlxIpzms=; From: Paul Durrant To: xen-devel@lists.xenproject.org Cc: Paul Durrant , Ian Jackson , Wei Liu , Anthony PERARD Subject: [PATCH v5 11/11] xl / libxl: add 'ex_processor_mask' into 'libxl_viridian_enlightenment' Date: Fri, 4 Dec 2020 08:52:55 +0000 Message-Id: <20201204085255.26216-12-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201204085255.26216-1-paul@xen.org> References: <20201204085255.26216-1-paul@xen.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) Content-Type: text/plain; charset="utf-8" From: Paul Durrant Adding the new value into the enumeration makes it immediately available to xl, so this patch adjusts the xl.cfg(5) documentation accordingly. Signed-off-by: Paul Durrant --- Cc: Ian Jackson Cc: Wei Liu Cc: Anthony PERARD --- docs/man/xl.cfg.5.pod.in | 8 ++++++++ tools/include/libxl.h | 7 +++++++ tools/libs/light/libxl_types.idl | 1 + tools/libs/light/libxl_x86.c | 3 +++ 4 files changed, 19 insertions(+) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index 0532739c1fff..3f0f8de1e988 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -2318,6 +2318,14 @@ This set incorporates use of a hypercall for interpr= ocessor interrupts. This enlightenment may improve performance of Windows guests with multiple virtual CPUs. =20 +=3Ditem B + +This set enables new hypercall variants taking a variably-sized sparse +B as an argument, rather than a simple 64-bit +mask. Hence this enlightenment must be specified for guests with more +than 64 vCPUs if B and/or B are also +specified. + =3Ditem B =20 This is a special value that enables the default set of groups, which diff --git a/tools/include/libxl.h b/tools/include/libxl.h index 1ea5b4f446e8..eaffccb30f37 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -444,6 +444,13 @@ */ #define LIBXL_HAVE_DISK_SAFE_REMOVE 1 =20 +/* + * LIBXL_HAVE_VIRIDIAN_EX_PROCESSOR_MASKS indicates that the + * 'ex_processor_masks' value is present in the viridian enlightenment + * enumeration. + */ +#define LIBXL_HAVE_VIRIDIAN_EX_PROCESSOR_MASKS 1 + /* * libxl ABI compatibility * diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_type= s.idl index 9d3f05f39978..05324736b744 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -238,6 +238,7 @@ libxl_viridian_enlightenment =3D Enumeration("viridian_= enlightenment", [ (7, "synic"), (8, "stimer"), (9, "hcall_ipi"), + (10, "ex_processor_masks"), ]) =20 libxl_hdtype =3D Enumeration("hdtype", [ diff --git a/tools/libs/light/libxl_x86.c b/tools/libs/light/libxl_x86.c index e18274cc10e2..86d272999d67 100644 --- a/tools/libs/light/libxl_x86.c +++ b/tools/libs/light/libxl_x86.c @@ -366,6 +366,9 @@ static int hvm_set_viridian_features(libxl__gc *gc, uin= t32_t domid, if (libxl_bitmap_test(&enlightenments, LIBXL_VIRIDIAN_ENLIGHTENMENT_HC= ALL_IPI)) mask |=3D HVMPV_hcall_ipi; =20 + if (libxl_bitmap_test(&enlightenments, LIBXL_VIRIDIAN_ENLIGHTENMENT_EX= _PROCESSOR_MASKS)) + mask |=3D HVMPV_ex_processor_masks; + if (mask !=3D 0 && xc_hvm_param_set(CTX->xch, domid, --=20 2.20.1