From nobody Fri Apr 19 14:37:13 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=1605865775; cv=none; d=zohomail.com; s=zohoarc; b=dI2Zb5BZ/i3lDmiKDp8D232+hwmU3LeK8Pa6YnCDTrWwff3eN1NLs9/5GRfcwQhMy3R0bbp9tOBU8P5uK20LMCeIawY2BhgxEgXLMiR7kB7D9gffqo8/ZDxlXGAS1Pkom6PSOt2Sos6aCCgeOzgdllcSREgzip4OEhylJiqvfWI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605865775; 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=oFMSo+GJNEgaaZ5yNsIGpJUzjgKARczCMDIFteDVII8=; b=DiO1tppJi7jgLk8nvVajVtvmbRbmqiBI+kaIV+fdBWOxxrc0otyj/lHwzPBV+bv+sfiQNk9LrdXpYAa1hD0JPfzgz0ty/FkwGBoJQKIAjNoMF8S+TWFUVJU+RlvNID9ZdC24sf9e2GPYJWgdsCx2GgzKXS5sQNTK4CDU+sS8so4= 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 160586577548147.32350166647211; Fri, 20 Nov 2020 01:49:35 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.31833.62554 (Exim 4.92) (envelope-from ) id 1kg32Q-0005Ai-4K; Fri, 20 Nov 2020 09:49:06 +0000 Received: by outflank-mailman (output) from mailman id 31833.62554; Fri, 20 Nov 2020 09:49: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 1kg32P-0005Aa-VA; Fri, 20 Nov 2020 09:49:05 +0000 Received: by outflank-mailman (input) for mailman id 31833; Fri, 20 Nov 2020 09:49:04 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32O-0005AR-Tw for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 09:49:04 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32O-0002aX-Gk; Fri, 20 Nov 2020 09:49:04 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32O-0003d1-8I; Fri, 20 Nov 2020 09:49:04 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32O-0005AR-Tw for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 09:49:04 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32O-0002aX-Gk; Fri, 20 Nov 2020 09:49:04 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32O-0003d1-8I; Fri, 20 Nov 2020 09:49: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=oFMSo+GJNEgaaZ5yNsIGpJUzjgKARczCMDIFteDVII8=; b=QOpyNdPhT/VqiSD/ey9qO6WGll xGgkiEFnZHs7lcBx8sj5zlk+M7aOizBTEaP3jwd9HgQQ3vpVVQnrdBItFkv8kSeF9MFvrZubFIgPu ffbY+8Rj04o1fgEsi0syfeZWjSRf9J5dGcZTjQnxuZAcl/plXyRRXUhHpzDBRDSHLOBE=; 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 v2 01/12] viridian: don't blindly write to 32-bit registers is 'mode' is invalid Date: Fri, 20 Nov 2020 09:48:49 +0000 Message-Id: <20201120094900.1489-2-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201120094900.1489-1-paul@xen.org> References: <20201120094900.1489-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" v2: - New in v2 --- xen/arch/x86/hvm/viridian/viridian.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/hvm/viridian/viridian.c b/xen/arch/x86/hvm/viridi= an/viridian.c index dc7183a54627..54035f75cb1a 100644 --- a/xen/arch/x86/hvm/viridian/viridian.c +++ b/xen/arch/x86/hvm/viridian/viridian.c @@ -692,13 +692,14 @@ int viridian_hypercall(struct cpu_user_regs *regs) break; } =20 -out: + out: output.result =3D status; 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 Apr 19 14:37:13 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=1605865776; cv=none; d=zohomail.com; s=zohoarc; b=NO/3D2dJoZvmHfxjb9uunhgiUoQ6rAJVzvpqeWraX7a1ZbD0wdu82q6KcwNlKjYTmsIc/3BM2AzhhoIwIZfFv2N2nV61QJl2J6vkKtVd9Gh+YRZ2bdFusTgR00oog+lxo4ei7/o4AN0fvTbgwX5L00yAdRoDUbhMdmesLrAAs+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605865776; 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=qhrQ5SA3XRDCClu4Afoub3CK4rPcgTdFaJdSe0ftLhc=; b=TRUJHTMFzseMGWbhJ43uSSPdEqnyOjmbSSqENCm40rvHtHiLWgkoYhWvG9hvh5mAuzMtmo3xLcdSEDceywb6e4616WqMmRVFGRE8cjvvfv1duwvsaKdZ+onxogpQvSsT/VjstukyIuEY4LgsAReXyp7VqK6Sw5k1BRbtTS2xEZo= 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 1605865775998570.6678294012219; Fri, 20 Nov 2020 01:49:35 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.31835.62575 (Exim 4.92) (envelope-from ) id 1kg32R-0005CX-18; Fri, 20 Nov 2020 09:49:07 +0000 Received: by outflank-mailman (output) from mailman id 31835.62575; Fri, 20 Nov 2020 09:49: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 1kg32Q-0005CB-Q3; Fri, 20 Nov 2020 09:49:06 +0000 Received: by outflank-mailman (input) for mailman id 31835; Fri, 20 Nov 2020 09:49:06 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32P-0005Ag-Vl for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 09:49:05 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32P-0002ag-Lu; Fri, 20 Nov 2020 09:49:05 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32P-0003d1-Ci; Fri, 20 Nov 2020 09:49:05 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32P-0005Ag-Vl for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 09:49:05 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32P-0002ag-Lu; Fri, 20 Nov 2020 09:49:05 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32P-0003d1-Ci; Fri, 20 Nov 2020 09:49: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=qhrQ5SA3XRDCClu4Afoub3CK4rPcgTdFaJdSe0ftLhc=; b=JhkFK1bPgMAptBhogqATsxuC/C W9E2A6LrTtyW18WXyMHJOiXZEA4/ix0Su1VSaCQjIlZogx6ne/4oD2A1X9mbQ0Wpp8XH04+6TlCeO UqZLL4MUY22CBNf+wx7vgKDCe1TtvpJCO3+oEpHxXmOxkwXmEBGozwTYzDE3G9t+eTcs=; 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 v2 02/12] viridian: move flush hypercall implementation into separate function Date: Fri, 20 Nov 2020 09:48:50 +0000 Message-Id: <20201120094900.1489-3-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201120094900.1489-1-paul@xen.org> References: <20201120094900.1489-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" --- 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 54035f75cb1a..15b1c96fe13b 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(union hypercall_input *input, + union hypercall_output *output, + unsigned long input_params_gpa, + unsigned long 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 Apr 19 14:37:13 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=1605865775; cv=none; d=zohomail.com; s=zohoarc; b=jZ9+5h+6yGbXGtHk8nWjYeNB4TS0D+VcccnLr8mN9McU8SNhwJEWbznpLTqRVFmf5mrLp8RgslYIbYmCpsnN7NR4j4rrXAOX1aaLg2X+CzFFeG+A6alUpFG+7WVnyj/9gw0hjOz2MTaymLULiGkI0tE5VPD3yDiP76AO8mVUKgM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605865775; 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=UzZ0Uh6qAAbQd6CRJaicCW7T27qr8iutib6QtzQf3Qs=; b=hjVTek7owQVbtJD5F7s/QPL0ABhm61xu9r1fJuNTBn1l1puLC4+HJmVP1vg7DepvOBq+yK5PqmnXDH2cVEvl8iAgoeaV1wnKTEUzU3Nm0Kt3Vt8jX+T96Sx3caCy/vP9vtolUfT6ZNAxLAwH0KefeK0wVcuobxo9thxwe1dfG7U= 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 1605865775509928.0186189164262; Fri, 20 Nov 2020 01:49:35 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.31836.62589 (Exim 4.92) (envelope-from ) id 1kg32S-0005Di-8c; Fri, 20 Nov 2020 09:49:08 +0000 Received: by outflank-mailman (output) from mailman id 31836.62589; Fri, 20 Nov 2020 09:49: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 1kg32S-0005Db-5R; Fri, 20 Nov 2020 09:49:08 +0000 Received: by outflank-mailman (input) for mailman id 31836; Fri, 20 Nov 2020 09:49:07 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32R-0005D3-6c for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 09:49:07 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32Q-0002ao-QH; Fri, 20 Nov 2020 09:49:06 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32Q-0003d1-HA; Fri, 20 Nov 2020 09:49:06 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32R-0005D3-6c for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 09:49:07 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32Q-0002ao-QH; Fri, 20 Nov 2020 09:49:06 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32Q-0003d1-HA; Fri, 20 Nov 2020 09:49: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=UzZ0Uh6qAAbQd6CRJaicCW7T27qr8iutib6QtzQf3Qs=; b=Z83ArtHr/q4BzPJ+73B+N5zptD mpZxigXEebDZ+spsfZ2M6t/tAQ8JJfEXdqAXVNzW0uYoNCycwGG9Th3xocX1XhBQARFOdVHw9wYY9 f+Kjkn9BZdl11jVjv1hAP8ZB3G8eWLyPL6+V2gNZ+4ImKqtqaFdt1MG928+3k5U6/RTE=; 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 v2 03/12] viridian: move IPI hypercall implementation into separate function Date: Fri, 20 Nov 2020 09:48:51 +0000 Message-Id: <20201120094900.1489-4-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201120094900.1489-1-paul@xen.org> References: <20201120094900.1489-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" 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 15b1c96fe13b..d9864cdc0b7d 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(union hypercall_input *input, return 0; } =20 +static int hvcall_ipi(union hypercall_input *input, + union hypercall_output *output, + unsigned long input_params_gpa, + unsigned long 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: regs->rax =3D output.raw; --=20 2.20.1 From nobody Fri Apr 19 14:37:13 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=1605865775; cv=none; d=zohomail.com; s=zohoarc; b=cV/VvYc6hP9Q3JNYZcLkhFfR3jFKw1R3mooBtZhAJvKOhf7biZu3ZPfFjrhHsTONqJKYsPYka/QiyqoGr3XVb4NiD1BcVIZUVCuvFtVM9N0XcTdkxHwXXLL2dCe8vfGq9FQLjUp3AkOkdcTdLMC0q4YmvKI0YtLdqmw602ee/IQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605865775; 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=4IjgffEuEnKUzkPcG7Uko4N1YazvYI/Qlj97s2cqBCg=; b=UC877hXpeZ3107wknVvFwc8WE3Fz+lpXqPAffwFEbATnswSfjIvUvoeVZOVtCiNoekiqJyNvBcAnHqwId0D2f3RnbcTEAJZhno5tfcmQvdgX91dW49RvXXkcr2Ps/W/BAOMShdLOJBxTJL0GG6Ucoyd9BzCVSeRGzwxSTvBver4= 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 1605865775289207.4208696916096; Fri, 20 Nov 2020 01:49:35 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.31837.62602 (Exim 4.92) (envelope-from ) id 1kg32T-0005GK-K8; Fri, 20 Nov 2020 09:49:09 +0000 Received: by outflank-mailman (output) from mailman id 31837.62602; Fri, 20 Nov 2020 09:49: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 1kg32T-0005G8-ER; Fri, 20 Nov 2020 09:49:09 +0000 Received: by outflank-mailman (input) for mailman id 31837; Fri, 20 Nov 2020 09:49:08 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32S-0005Dl-8Q for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 09:49:08 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32R-0002ax-TV; Fri, 20 Nov 2020 09:49:07 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32R-0003d1-LL; Fri, 20 Nov 2020 09:49:07 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32S-0005Dl-8Q for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 09:49:08 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32R-0002ax-TV; Fri, 20 Nov 2020 09:49:07 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32R-0003d1-LL; Fri, 20 Nov 2020 09:49:07 +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=4IjgffEuEnKUzkPcG7Uko4N1YazvYI/Qlj97s2cqBCg=; b=S/HE5+4x9GMOk4dbcXx475CQip 048rsSSEQodcBZgPP7ozR4YFkR4C9msBDMUBZ35LzAQ6dH+uY2Y4JQBD6PYXClpCIc7nqPQuTsqN7 yOaigimt5tjyDY1as8zr2wZ5SWhOGo7tbIJ3Soq1DcibVSp9fsAnQu/0qqVtejpVObIU=; 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 v2 04/12] viridian: introduce a per-cpu hypercall_vpmask and accessor functions... Date: Fri, 20 Nov 2020 09:48:52 +0000 Message-Id: <20201120094900.1489-5-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201120094900.1489-1-paul@xen.org> References: <20201120094900.1489-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 d9864cdc0b7d..334d8527ff59 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(union hypercall_input *input, unsigned long input_params_gpa, unsigned long 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(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 Apr 19 14:37:13 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=1605865775; cv=none; d=zohomail.com; s=zohoarc; b=j7EkwQohFB3CTGlb6sZoAIasgEA1zKoqcvyQXO1gdpmvo3Xp3Vgw6+eNw95QNcUqOk7TWzvkSOnCGu/O/qYCpVwG+pmCgpLz/evEYxvfICpxBZJC7hUrxZ0k6eVZZ3B+eKEnpz4jdNgeS6DrSqDO+B78w9I00qZeGqOjKTRBPjA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605865775; 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=Ie9PO+o0rvIAgtu6WNO10yIOs6iLnaU4in65atV0VQo=; b=MV9OknEBXfrW7kuQ38FiW2V49knTzo9HGdhlLuwcXnj5Ttp6Jt1C14Rp5ckY2GkLjzC64OGlQbHY/NmfBvDUjCJvV9OswyyF4Ah8/+s05CXl9m1EW5MVG6t2vmCNF34M796DjVzUWSc1bI7wshTKRhfhbTmK4lTT/YliYjcWU3c= 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 1605865775324608.3512573210312; Fri, 20 Nov 2020 01:49:35 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.31838.62614 (Exim 4.92) (envelope-from ) id 1kg32U-0005Ix-SY; Fri, 20 Nov 2020 09:49:10 +0000 Received: by outflank-mailman (output) from mailman id 31838.62614; Fri, 20 Nov 2020 09:49:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32U-0005In-Ny; Fri, 20 Nov 2020 09:49:10 +0000 Received: by outflank-mailman (input) for mailman id 31838; Fri, 20 Nov 2020 09:49:09 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32T-0005Fv-82 for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 09:49:09 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32T-0002b7-1R; Fri, 20 Nov 2020 09:49:09 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32S-0003d1-Pk; Fri, 20 Nov 2020 09:49:09 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32T-0005Fv-82 for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 09:49:09 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32T-0002b7-1R; Fri, 20 Nov 2020 09:49:09 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32S-0003d1-Pk; Fri, 20 Nov 2020 09:49: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:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=Ie9PO+o0rvIAgtu6WNO10yIOs6iLnaU4in65atV0VQo=; b=gnp2dlZA0e7aR/3BvFD3stzOWH A1BZx8iZK2Y4sf4HB69F3sRKG/RPFfATyGo4WyT/uDS4EznqJNSrgvjAeFem6DKqMrkIaySJmAkxK PoL1J7qBlrXVNZM1HzDbxVv7qFbxvNRjWxgM6/pp+TzKiRH/QvBiMYS9Cv3G+eeZ6zqs=; 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 v2 05/12] viridian: use hypercall_vpmask in hvcall_ipi() Date: Fri, 20 Nov 2020 09:48:53 +0000 Message-Id: <20201120094900.1489-6-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201120094900.1489-1-paul@xen.org> References: <20201120094900.1489-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" v2: - Drop the 'vp' loop now that vpmask_set() will do it internally --- xen/arch/x86/hvm/viridian/viridian.c | 43 +++++++++++++++++++++------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/hvm/viridian/viridian.c b/xen/arch/x86/hvm/viridi= an/viridian.c index 334d8527ff59..d8d8ecc89c80 100644 --- a/xen/arch/x86/hvm/viridian/viridian.c +++ b/xen/arch/x86/hvm/viridian/viridian.c @@ -551,6 +551,25 @@ static bool vpmask_test(const struct hypercall_vpmask = *vpmask, return test_bit(vp, vpmask->mask); } =20 +static unsigned int vpmask_first(struct hypercall_vpmask *vpmask) +{ + return find_first_bit(vpmask->mask, HVM_MAX_VCPUS); +} + +static unsigned int vpmask_next(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 +650,21 @@ static int hvcall_flush(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(union hypercall_input *input, union hypercall_output *output, unsigned long input_params_gpa, unsigned long 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 +703,10 @@ static int hvcall_ipi(union hypercall_input *input, 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 Apr 19 14:37:13 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=1605865775; cv=none; d=zohomail.com; s=zohoarc; b=a2yjUT9vORNKKh4P9mxW3xtf2hJgG249HykiO12dURcVQdYL0PVSyL+yOu2bBn64JrNkRCW7+sugeLDHGC3Uh0SrHv34OWIb3bIaGnCeAfXDouvJBoRgR0O0xR8yjzGOs/k6sMIFo2OKNAPSLorAU9c8b7kyYltqq/uIjybGaHQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605865775; 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=WvuwwpXtHIjcO9NlLF0rzPVaiYPqjWXaNgyK1WMlZ8U=; b=b4Jk4Rx48Avw7Eqtq0YiOOVtypDvYeKcWa8GAo5LRTzE/bQaryA6ufqea8/4lri0w2L4nGr9+FQPeCXsA9+0wOXalMWO7vLkcO5QFE0ORZVXY6D2irgStFQjbm2puKfnoDTAiQCIJE84s0XSqA4tST1AlIgkvniQRMQ2M45AUdg= 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 1605865775806551.1536568608126; Fri, 20 Nov 2020 01:49:35 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.31839.62620 (Exim 4.92) (envelope-from ) id 1kg32V-0005Jr-CH; Fri, 20 Nov 2020 09:49:11 +0000 Received: by outflank-mailman (output) from mailman id 31839.62620; Fri, 20 Nov 2020 09:49:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32V-0005JR-10; Fri, 20 Nov 2020 09:49:11 +0000 Received: by outflank-mailman (input) for mailman id 31839; Fri, 20 Nov 2020 09:49:10 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32U-0005IB-8N for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 09:49:10 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32U-0002bG-5k; Fri, 20 Nov 2020 09:49:10 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32T-0003d1-U8; Fri, 20 Nov 2020 09:49:10 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32U-0005IB-8N for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 09:49:10 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32U-0002bG-5k; Fri, 20 Nov 2020 09:49:10 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32T-0003d1-U8; Fri, 20 Nov 2020 09:49:10 +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=WvuwwpXtHIjcO9NlLF0rzPVaiYPqjWXaNgyK1WMlZ8U=; b=HTeXAkg4QeahXXWEcacrgWgUKq 7SgIVGWC5T/JtLEyEBCLKtYlFzrQcDejLNm93hzt+2X5P6rs43IgAcOVZphuVSS/GCqIyRPBQVo9F 0HXT2qaB8HG/j2UYW8aTEz5T7fcrrOZI83Q1o+xgF1AhmNfLI7S8Tx1KkAvubFtnsQ1o=; 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 v2 06/12] viridian: use softirq batching in hvcall_ipi() Date: Fri, 20 Nov 2020 09:48:54 +0000 Message-Id: <20201120094900.1489-7-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201120094900.1489-1-paul@xen.org> References: <20201120094900.1489-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: Jan Beulich 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 d8d8ecc89c80..d6f47b28c1e6 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 @@ -570,6 +571,11 @@ static unsigned int vpmask_next(struct hypercall_vpmas= k *vpmask, unsigned int vp (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. @@ -653,10 +659,17 @@ static int hvcall_flush(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(union hypercall_input *input, --=20 2.20.1 From nobody Fri Apr 19 14:37:13 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=1605865775; cv=none; d=zohomail.com; s=zohoarc; b=GYZlsRnUSIWTpr8ynkL/UMO6ItUoPJGRQ+Z7Ip1Ao2AYL7CJvHZueQH/VZKvbfj5tm0+DRfb+BuOHPAPCxIUJ1+VClfiPrelkrhDW6Aus2WUZFZKhaRvlYfFzYb5Rvlc0sDVK8dJZ4zly285igVFquKuGWx8x2KPIfAqg6N+g4Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605865775; 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=ur98iexNlxW3wPnCoGH5R8tJsU4anFW0cgN61u59s58=; b=L1MYPGJbr9gMogGpCvI94OA2l5S6tLZ3siCBXBDxRx1oG/9YEN2hj2ZZpZ14suIu6rM1qOSN38DrUtd5ZDHELv3dSPetqReEcqmhU2mYt+8XgaV6MtYCMk1rxDEaKwHnjW6vM0tMMMChvg1WKcdYErINy4jKc2nN8bgsri7Z/bM= 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 1605865775432489.96449192316845; Fri, 20 Nov 2020 01:49:35 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.31840.62638 (Exim 4.92) (envelope-from ) id 1kg32X-0005PV-Tm; Fri, 20 Nov 2020 09:49:13 +0000 Received: by outflank-mailman (output) from mailman id 31840.62638; Fri, 20 Nov 2020 09:49:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32X-0005PI-OC; Fri, 20 Nov 2020 09:49:13 +0000 Received: by outflank-mailman (input) for mailman id 31840; Fri, 20 Nov 2020 09:49:12 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32W-0005Mr-Dk for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 09:49:12 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32V-0002bN-Jp; Fri, 20 Nov 2020 09:49:11 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32V-0003d1-Bu; Fri, 20 Nov 2020 09:49:11 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32W-0005Mr-Dk for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 09:49:12 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32V-0002bN-Jp; Fri, 20 Nov 2020 09:49:11 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32V-0003d1-Bu; Fri, 20 Nov 2020 09:49:11 +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=ur98iexNlxW3wPnCoGH5R8tJsU4anFW0cgN61u59s58=; b=EbmX6KfTkfVSVhcM7nRxkqW8q1 cP83sNOja9lntToF+lbfAB3WxN/n4OG8WM/rBZz55JBZvx3uqvq/S5dgGVU4ZtpzS/WERLLDgFUTM F8kf/CA4Gm7mPnxLhbcE8GQQkycbRgDjWAVmPv8yuB5bKBv3k5gDPF5UFcV6VBHOZ5tg=; From: Paul Durrant To: xen-devel@lists.xenproject.org Cc: Paul Durrant , Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [PATCH v2 07/12] xen/include: import sizeof_field() macro from Linux stddef.h Date: Fri, 20 Nov 2020 09:48:55 +0000 Message-Id: <20201120094900.1489-8-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201120094900.1489-1-paul@xen.org> References: <20201120094900.1489-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 Co-locate it with the definition of offsetof() (since this is also in stdde= f.h in the Linux kernel source). This macro will be needed in a subsequent patc= h. Signed-off-by: Paul Durrant Acked-by: Jan Beulich --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Julien Grall Cc: Stefano Stabellini Cc: Wei Liu --- xen/include/xen/compiler.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xen/include/xen/compiler.h b/xen/include/xen/compiler.h index c0e0ee9f27be..676c6ea1b0a0 100644 --- a/xen/include/xen/compiler.h +++ b/xen/include/xen/compiler.h @@ -76,6 +76,14 @@ =20 #define offsetof(a,b) __builtin_offsetof(a,b) =20 +/** + * sizeof_field(TYPE, MEMBER) + * + * @TYPE: The structure containing the field of interest + * @MEMBER: The field to return the size of + */ +#define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER)) + #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L #define alignof __alignof__ #endif --=20 2.20.1 From nobody Fri Apr 19 14:37:13 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=1605865776; cv=none; d=zohomail.com; s=zohoarc; b=g4SDkn1nP1YBepEUq8Ws5Fs+mpGYynIlVDYvKnzFn5DSvk6UubQuVVSOKMjrX4Gj9rn+0GrjPEefL5XVoxTBeJaEAfWw/Z11jDKuGuvGX/H9WDE7IbR1LmP+qHJ7/Ex4Y7lkNOKSjcf8vO9Cc1SHsPtCoAF/f8wJGzNoPB0RipE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605865776; 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=3DPdSem6nkuIEJJrD8PvA4dT/KiTua7xMj10EiGKfcs=; b=Cv0o2xyWwlnacCuzWQbRE/ZduXTRkQNisIxniSiDqw3FY7ehZgVV8xftfw+gXsM2h/yh9CfyYxit7K2RApxfMw6MZ73a8hgTMhI+qHApguhK6gWIs91fyD+gRf+5SoIpvdrvFFKnxy34i/09UaHehdytKx+Yn60pRHSq/rSWzlg= 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 1605865776148937.0756071076544; Fri, 20 Nov 2020 01:49:36 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.31841.62645 (Exim 4.92) (envelope-from ) id 1kg32Y-0005QZ-Mc; Fri, 20 Nov 2020 09:49:14 +0000 Received: by outflank-mailman (output) from mailman id 31841.62645; Fri, 20 Nov 2020 09:49:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32Y-0005Q7-5U; Fri, 20 Nov 2020 09:49:14 +0000 Received: by outflank-mailman (input) for mailman id 31841; Fri, 20 Nov 2020 09:49:13 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32X-0005OG-05 for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 09:49:13 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32W-0002bU-PR; Fri, 20 Nov 2020 09:49:12 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32W-0003d1-GC; Fri, 20 Nov 2020 09:49:12 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32X-0005OG-05 for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 09:49:13 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32W-0002bU-PR; Fri, 20 Nov 2020 09:49:12 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32W-0003d1-GC; Fri, 20 Nov 2020 09:49:12 +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=3DPdSem6nkuIEJJrD8PvA4dT/KiTua7xMj10EiGKfcs=; b=KJU6mAPnc8ruDs1uB7bGJPrkay jzetR3GNO2fosrikXijWv7Z0epPXuyVcWLd/g0u61LnKMGtryEEY5GkPNNC+8tcGXuT52gaj85VOv HQkICSlJXQ5WVgCxxMGNzFWG2R0bU1DQ0M9X5P7FQsQQlVqOSJvSdzcWAmJjUlrExa74=; 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 v2 08/12] viridian: add ExProcessorMasks variants of the flush hypercalls Date: Fri, 20 Nov 2020 09:48:56 +0000 Message-Id: <20201120094900.1489-9-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201120094900.1489-1-paul@xen.org> References: <20201120094900.1489-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" 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 | 142 +++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) diff --git a/xen/arch/x86/hvm/viridian/viridian.c b/xen/arch/x86/hvm/viridi= an/viridian.c index d6f47b28c1e6..e736c0739da0 100644 --- a/xen/arch/x86/hvm/viridian/viridian.c +++ b/xen/arch/x86/hvm/viridian/viridian.c @@ -576,6 +576,70 @@ 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) \ + (sizeof(struct hv_vpset) + (banks * HV_VPSET_BANK_SIZE)) + +#define HV_VPSET_MAX_BANKS \ + (sizeof_field(struct hv_vpset, valid_bank_mask) * 8) + +struct hypercall_vpset { + union { + struct hv_vpset set; + uint8_t pad[HV_VPSET_SIZE(HV_VPSET_MAX_BANKS)]; + }; +}; + +static DEFINE_PER_CPU(struct 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(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. @@ -656,6 +720,78 @@ static int hvcall_flush(union hypercall_input *input, return 0; } =20 +static int hvcall_flush_ex(union hypercall_input *input, + union hypercall_output *output, + unsigned long input_params_gpa, + unsigned long 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 + { + struct 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; @@ -769,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 Apr 19 14:37:13 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=1605865775; cv=none; d=zohomail.com; s=zohoarc; b=nE/xoPu0xSUUpzG/h4YjKVsu0Wce0Co1kiCBKwEUcOzOYwi8k4wJ9LtF2fpuqQUC+2umkaCywRfFXxGywgostPJiMDy1cAMCj7w97KBibd3Iot/NBPM1RqIgJ/7tJcR8T24DoBvamXq32+ZmiU+74mG2bg5at9azwR0iSeLn6Fk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605865775; 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=rH60KaFb4nQd7ulI+9/biFMC6TXsBA8iRybF1TD4Eko=; b=Nt8yImCTQq7QhTQfgnnjxxm58oPyG0X7LWLc5aHcJo99lPtC5jKVLHqjJKtjvCYQfZ2EKVkw8nG/lmK6/NYmTnk/Q9IDNHBIXKty0lVfY0rKmsJLugJ6TRjXKvKK6WV3T5VOZljhtfCnYSmYO4SHKUgd6Q9ghga8i3UCs+F7p08= 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 1605865775259201.7527281706665; Fri, 20 Nov 2020 01:49:35 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.31842.62662 (Exim 4.92) (envelope-from ) id 1kg32a-0005Um-1O; Fri, 20 Nov 2020 09:49:16 +0000 Received: by outflank-mailman (output) from mailman id 31842.62662; Fri, 20 Nov 2020 09:49:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32Z-0005UJ-Lm; Fri, 20 Nov 2020 09:49:15 +0000 Received: by outflank-mailman (input) for mailman id 31842; Fri, 20 Nov 2020 09:49:14 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32Y-0005Px-3A for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 09:49:14 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32X-0002bc-SN; Fri, 20 Nov 2020 09:49:13 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32X-0003d1-Ke; Fri, 20 Nov 2020 09:49:13 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32Y-0005Px-3A for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 09:49:14 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32X-0002bc-SN; Fri, 20 Nov 2020 09:49:13 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32X-0003d1-Ke; Fri, 20 Nov 2020 09:49:13 +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=rH60KaFb4nQd7ulI+9/biFMC6TXsBA8iRybF1TD4Eko=; b=3q1KexrHeX/aaEAH76gfFPGqyd zJ20hL+j4OziLbxE1NanvJ79ZWJr8lyYsP3zJMD3ujeMtDzvOyn5zPXnF6X1AA2jgtSh9b4FiOhpE W9HeuAtNoWGa3KXHMlL2n4mgh3HXLYfhd58kol1TVO0w99tE9ngrZ1CJ+4n1eWgdOUn4=; 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 v2 09/12] viridian: add ExProcessorMasks variant of the IPI hypercall Date: Fri, 20 Nov 2020 09:48:57 +0000 Message-Id: <20201120094900.1489-10-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201120094900.1489-1-paul@xen.org> References: <20201120094900.1489-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" 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 e736c0739da0..74227fecbcd4 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(union hypercall_input *input, return 0; } =20 +static int hvcall_ipi_ex(union hypercall_input *input, + union hypercall_output *output, + unsigned long input_params_gpa, + unsigned long 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; + struct 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 Apr 19 14:37:13 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=1605866464; cv=none; d=zohomail.com; s=zohoarc; b=SaSv/MJda3qEiucZE41J/7069hb1HdWupdjFqw5F99U/sebek0CQMr5UUzHEdpvx+UylWwhqoLHeJdWFi7I0tXvk1dffCqWxD7E9Begdz3KN7t0W4Y512vdOujWB6INOpy0AC6tFtg0hPsxIUgj7RKHkv1icKCCWpHOzeBjRK4c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605866464; 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=Xc3dEZvBV1+eTUG9QjtZCF0WCwEhmm9IyrdLoFO3fio=; b=eGW3VsIPqa/92XIGenTK12XxINcAO+KpzC1WzGCH3+/AxE1IC9EApp868EZ5LiB616jDlDAXzN5c9mEiJH9a9uLzUYgFz4XLp3icrlY/yLLfbXXwstqLgOgLvaFwqr4RMq3WRUflfP1wB1S42cMBFQjR9zZR3wadi9Y8iVrwFiY= 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 1605866464824874.7554600902105; Fri, 20 Nov 2020 02:01:04 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.31904.62685 (Exim 4.92) (envelope-from ) id 1kg3Di-0000Aq-8l; Fri, 20 Nov 2020 10:00:46 +0000 Received: by outflank-mailman (output) from mailman id 31904.62685; Fri, 20 Nov 2020 10: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 1kg3Di-0000Ab-5c; Fri, 20 Nov 2020 10:00:46 +0000 Received: by outflank-mailman (input) for mailman id 31904; Fri, 20 Nov 2020 10:00:44 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg3Dg-0000AE-Na for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 10:00:44 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg3Dg-0002vf-9h; Fri, 20 Nov 2020 10:00:44 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32Y-0003d1-P4; Fri, 20 Nov 2020 09:49:14 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg3Dg-0000AE-Na for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 10:00:44 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg3Dg-0002vf-9h; Fri, 20 Nov 2020 10:00:44 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32Y-0003d1-P4; Fri, 20 Nov 2020 09:49:14 +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=Xc3dEZvBV1+eTUG9QjtZCF0WCwEhmm9IyrdLoFO3fio=; b=EgvdqzPzkqvxm+WD2HNz97iqIl JjZQ6vw0ArmB5yqjwqUdelNFJbhUbdo3ZMWa9EHc/i75hm4tk2dR3H5s16L9kcfGeYwb+GxvGeDMf tHTfYzOc//lamGsnmJzkoq8pR/uuUQS/oslh4Xt/tGawgZQiohupymjwp9bmXqbeQm6k=; 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 v2 10/12] viridian: log initial invocation of each type of hypercall Date: Fri, 20 Nov 2020 09:48:58 +0000 Message-Id: <20201120094900.1489-11-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201120094900.1489-1-paul@xen.org> References: <20201120094900.1489-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 74227fecbcd4..de3f5f86777c 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 Apr 19 14:37:13 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=1605866464; cv=none; d=zohomail.com; s=zohoarc; b=hOXxf6mqnN3bSIRPEF7nfPMVyS2a6a/t8mH8Hys95DryFrTd3plUE+Ei+rgMg6vsHte368p7/yTSeX64yND+rLlGEUl0nwTQEAZ5G7ziU8KQPevORmQqP2FKxKMbEABlAMskVnv8rm/puJ8pWrR1icMSpuOYO8wgFH61SUQo7p0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605866464; 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=/q8/4ovlXCcgIYS3O6ZCn2GAgqJ29SC66Zw3QGsg0QU=; b=VOMMeyXjCTtnBsJtJyoCprmJJqANixqTJPV1BTuTtYlQml39GE8tQAIT/CTebzIP1r/t32dfYwj7bVgRK6J0R+ZQZHhrFrflcRiOWGoxediURSwGDILtOw4OqIzQlcW8mF0004BiW0XVONk3tCVnre0dHOaQA8F/ziYwj/mV3Kw= 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 1605866464825238.214815038677; Fri, 20 Nov 2020 02:01:04 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.31906.62705 (Exim 4.92) (envelope-from ) id 1kg3Dj-0000Cf-61; Fri, 20 Nov 2020 10:00:47 +0000 Received: by outflank-mailman (output) from mailman id 31906.62705; Fri, 20 Nov 2020 10:00:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg3Di-0000C8-RN; Fri, 20 Nov 2020 10:00:46 +0000 Received: by outflank-mailman (input) for mailman id 31906; Fri, 20 Nov 2020 10:00:45 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg3Dh-0000AQ-4k for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 10:00:45 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg3Dg-0002vd-7M; Fri, 20 Nov 2020 10:00:44 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32a-0003d1-Ac; Fri, 20 Nov 2020 09:49:16 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg3Dh-0000AQ-4k for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 10:00:45 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg3Dg-0002vd-7M; Fri, 20 Nov 2020 10:00:44 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32a-0003d1-Ac; Fri, 20 Nov 2020 09:49:16 +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=/q8/4ovlXCcgIYS3O6ZCn2GAgqJ29SC66Zw3QGsg0QU=; b=IspVjfZySKMpAEaQTeTgVHxRx2 bjbuIc5e+fq+zFF24VBF0Ua0/X0FOuBlTEIvA0C6amY8t+nqNVqut+Yb3071oVB0T7YfyTmpRWnrw pYLZl6P760bxMRRtG+JujIr21Vqm2BpQcJ8tJK/aBmMM+o9uCuPHBkIfd42xYaxGTd/A=; 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 v2 11/12] viridian: add a new '_HVMPV_ex_processor_masks' bit into HVM_PARAM_VIRIDIAN... Date: Fri, 20 Nov 2020 09:48:59 +0000 Message-Id: <20201120094900.1489-12-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201120094900.1489-1-paul@xen.org> References: <20201120094900.1489-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 de3f5f86777c..54b20188e326 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 Apr 19 14:37:13 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=1605866462; cv=none; d=zohomail.com; s=zohoarc; b=Y39urLV2xEFEqhMSISmXKm7rbwYWrYgVx1mSYWDdqTZj5Y+hfvstlntyGnHnZemPo+MsOA8pqQj/gthfMEmdyZXL+WcJtIQnbDtecXf3ZKA7v1nMwoPW+CPHV3wPK4GHu/IVysIAIOWzZ53NtDoScaJMKZ3USYpvYl2nJXqJktE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605866462; 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=ZrfuOf3e7K+CfPa3V1ViyDs5NkkdPV22yToCzL+fm+42o0vIW8KGwHwgXygQ6a6kXZe6Q+DjkHhpCAG7K1vcBXIuMjuNROPK1jhmJ3O49KVPV3TYsmnD8aHkuWW1GSjwjj0JcmKQjCwY27FnWasReVa0npHAtZZuIMBDS0MUA64= 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 1605866462935689.4568783481462; Fri, 20 Nov 2020 02:01:02 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.31905.62695 (Exim 4.92) (envelope-from ) id 1kg3Di-0000BR-Ni; Fri, 20 Nov 2020 10:00:46 +0000 Received: by outflank-mailman (output) from mailman id 31905.62695; Fri, 20 Nov 2020 10: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 1kg3Di-0000BC-Db; Fri, 20 Nov 2020 10:00:46 +0000 Received: by outflank-mailman (input) for mailman id 31905; Fri, 20 Nov 2020 10:00:45 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg3Dh-0000AK-2w for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 10:00:45 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg3Dg-0002vb-0J; Fri, 20 Nov 2020 10:00:44 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32b-0003d1-Bb; Fri, 20 Nov 2020 09:49:17 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg3Dh-0000AK-2w for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 10:00:45 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg3Dg-0002vb-0J; Fri, 20 Nov 2020 10:00:44 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32b-0003d1-Bb; Fri, 20 Nov 2020 09:49:17 +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=aljZn49SbQde/x5Nfc4qojAcC9 PmWnCmYLuahJRepbdlcp7D10Hf7/4GZGlmy4UacseYU3bW0hcFi4rzFS5VtVbEXZSyZ6HDF3UQIyW BgIbKsJb5C6OoEFWjSnKcH9N0A5eWc42xHT6tgBvcneNt0Dli+cysl18664ZNsNtqc4U=; From: Paul Durrant To: xen-devel@lists.xenproject.org Cc: Paul Durrant , Ian Jackson , Wei Liu , Anthony PERARD Subject: [PATCH v2 12/12] xl / libxl: add 'ex_processor_mask' into 'libxl_viridian_enlightenment' Date: Fri, 20 Nov 2020 09:49:00 +0000 Message-Id: <20201120094900.1489-13-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201120094900.1489-1-paul@xen.org> References: <20201120094900.1489-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