From patchwork Thu Apr 3 18:23:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin X-Patchwork-Id: 14037510 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9EA47C3600C for ; Thu, 3 Apr 2025 18:23:43 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.937064.1338166 (Exim 4.92) (envelope-from ) id 1u0PDx-0002Va-P9; Thu, 03 Apr 2025 18:23:33 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 937064.1338166; Thu, 03 Apr 2025 18:23:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u0PDx-0002VT-M0; Thu, 03 Apr 2025 18:23:33 +0000 Received: by outflank-mailman (input) for mailman id 937064; Thu, 03 Apr 2025 18:23:32 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u0PDw-0001N1-Mo for xen-devel@lists.xenproject.org; Thu, 03 Apr 2025 18:23:32 +0000 Received: from mail-24417.protonmail.ch (mail-24417.protonmail.ch [109.224.244.17]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id bec5eddf-10b8-11f0-9ffb-bf95429c2676; Thu, 03 Apr 2025 20:23:31 +0200 (CEST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: bec5eddf-10b8-11f0-9ffb-bf95429c2676 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1743704610; x=1743963810; bh=GQ/7FVabQDdWQQqA2ckOWpneHtYQWqdMr/r/gKDzsXM=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=FdEBnhhYepTdHVUzupYP2bMsW8MZKaFZoa8hR6sBqIZQM1f3tH0wrZvfE3SVTsCVA wpXf4hp6GVGyoRnLJ7GpGjL+aB1HP4gDwQJ2zAg0GTr7fwJ1wNgCrxc5BqSf7ikgBh 2HIlhN3ryC3V4q22iAgf2TXWDFCEUJhz61bAyg37TbFTjZeQazc46biHas9apQXjPV /RyU3+/2k96ShaxvW/O4tmwkzjVXsshKMXxbSpzqFOVTdyVllDTNS0+OJe0PIsE77H LboVB6CqUWTLcRE0FHTDMwTkQODqlV33GeejjXJWP9fQAlWVebyWGEr3cJlsjp/2hm BnNgdskJi7xLA== Date: Thu, 03 Apr 2025 18:23:26 +0000 To: xen-devel@lists.xenproject.org From: dmkhn@proton.me Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v2 5/6] x86/emulate: remove HAVE_AS_RDRAND and HAVE_AS_RDSEED Message-ID: <20250403182250.3329498-6-dmukhin@ford.com> In-Reply-To: <20250403182250.3329498-1-dmukhin@ford.com> References: <20250403182250.3329498-1-dmukhin@ford.com> Feedback-ID: 123220910:user:proton X-Pm-Message-ID: 8dd76c2aceb6a141989cabe4dc4ca563e968872c MIME-Version: 1.0 From: Denis Mukhin The new toolchain baseline knows the rdrand/rdseed instructions, no need to carry the workaround in the code. Resolves: https://gitlab.com/xen-project/xen/-/work_items/208 Signed-off-by: Denis Mukhin --- xen/arch/x86/arch.mk | 2 -- xen/arch/x86/x86_emulate/0fc7.c | 15 +++++---------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/arch.mk b/xen/arch/x86/arch.mk index 3bbaee2a44..5577bf6241 100644 --- a/xen/arch/x86/arch.mk +++ b/xen/arch/x86/arch.mk @@ -10,9 +10,7 @@ CFLAGS += -msoft-float $(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS)) $(call cc-option-add,CFLAGS,CC,-Wnested-externs) -$(call as-option-add,CFLAGS,CC,"rdrand %eax",-DHAVE_AS_RDRAND) $(call as-option-add,CFLAGS,CC,"xsaveopt (%rax)",-DHAVE_AS_XSAVEOPT) -$(call as-option-add,CFLAGS,CC,"rdseed %eax",-DHAVE_AS_RDSEED) $(call as-option-add,CFLAGS,CC,"clwb (%rax)",-DHAVE_AS_CLWB) $(call as-option-add,CFLAGS,CC,".equ \"x\"$(comma)1",-DHAVE_AS_QUOTED_SYM) $(call as-option-add,CFLAGS,CC,"movdiri %rax$(comma)(%rax)",-DHAVE_AS_MOVDIR) diff --git a/xen/arch/x86/x86_emulate/0fc7.c b/xen/arch/x86/x86_emulate/0fc7.c index 5268d5cafd..58c8f79501 100644 --- a/xen/arch/x86/x86_emulate/0fc7.c +++ b/xen/arch/x86/x86_emulate/0fc7.c @@ -32,7 +32,6 @@ int x86emul_0fc7(struct x86_emulate_state *s, return X86EMUL_UNRECOGNIZED; case 6: /* rdrand */ -#ifdef HAVE_AS_RDRAND generate_exception_if(s->vex.pfx >= vex_f3, X86_EXC_UD); host_and_vcpu_must_have(rdrand); *dst = s->ea; @@ -43,12 +42,12 @@ int x86emul_0fc7(struct x86_emulate_state *s, : "=r" (dst->val), ASM_FLAG_OUT("=@ccc", "=qm") (carry) ); break; default: -# ifdef __x86_64__ +#ifdef __x86_64__ asm ( "rdrand %k0" ASM_FLAG_OUT(, "; setc %1") : "=r" (dst->val), ASM_FLAG_OUT("=@ccc", "=qm") (carry) ); break; case 8: -# endif +#endif asm ( "rdrand %0" ASM_FLAG_OUT(, "; setc %1") : "=r" (dst->val), ASM_FLAG_OUT("=@ccc", "=qm") (carry) ); break; @@ -57,9 +56,6 @@ int x86emul_0fc7(struct x86_emulate_state *s, if ( carry ) regs->eflags |= X86_EFLAGS_CF; break; -#else - return X86EMUL_UNIMPLEMENTED; -#endif case 7: /* rdseed / rdpid */ if ( s->vex.pfx == vex_f3 ) /* rdpid */ @@ -77,7 +73,7 @@ int x86emul_0fc7(struct x86_emulate_state *s, dst->bytes = 4; break; } -#ifdef HAVE_AS_RDSEED + generate_exception_if(s->vex.pfx >= vex_f3, X86_EXC_UD); host_and_vcpu_must_have(rdseed); *dst = s->ea; @@ -88,12 +84,12 @@ int x86emul_0fc7(struct x86_emulate_state *s, : "=r" (dst->val), ASM_FLAG_OUT("=@ccc", "=qm") (carry) ); break; default: -# ifdef __x86_64__ +#ifdef __x86_64__ asm ( "rdseed %k0" ASM_FLAG_OUT(, "; setc %1") : "=r" (dst->val), ASM_FLAG_OUT("=@ccc", "=qm") (carry) ); break; case 8: -# endif +#endif asm ( "rdseed %0" ASM_FLAG_OUT(, "; setc %1") : "=r" (dst->val), ASM_FLAG_OUT("=@ccc", "=qm") (carry) ); break; @@ -102,7 +98,6 @@ int x86emul_0fc7(struct x86_emulate_state *s, if ( carry ) regs->eflags |= X86_EFLAGS_CF; break; -#endif } } else