From nobody Fri May 17 01:43:43 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; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1712849021; cv=none; d=zohomail.com; s=zohoarc; b=hlZ+pfTnkZcWEZI7KGVU/nlpcppg5R9pl1Srr4cdJwpuUmMBhpFAidQbYwi+fhww6LqJgkOSTV6fYd9YetF1vfHadmG6hEMjAAiuCJisczJGBQFamTFrO8ZHUayjmv++41WqkogfdtO6HpsYIG9phLApOdFfPEsOrI3KQX17r8A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1712849021; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Kvx5iWu0y4pMcC1rcy3iKy6ujT2KOD9cF1Frc/ddC/k=; b=RUn1NXNz4IpjHLKqz9vHMIk9yMG6NLqe8zhLiQBvUv1GAxomEI2lRIouNeo0UiedCO5YEYM018MszEyUuRw8maNpzRcxQMEtnyHcEWaa5G0V03Pax1FHuAU7REqRukx9WKK8gFfFSiYO3SChTRsQjEW4sCfCsigUwKQi2orJOzo= 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; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1712849021704793.7457751868635; Thu, 11 Apr 2024 08:23:41 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.703987.1100032 (Exim 4.92) (envelope-from ) id 1ruwGl-0007zC-7U; Thu, 11 Apr 2024 15:23:19 +0000 Received: by outflank-mailman (output) from mailman id 703987.1100032; Thu, 11 Apr 2024 15:23:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ruwGl-0007z5-3v; Thu, 11 Apr 2024 15:23:19 +0000 Received: by outflank-mailman (input) for mailman id 703987; Thu, 11 Apr 2024 15:23:18 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ruwGk-0007yz-IM for xen-devel@lists.xenproject.org; Thu, 11 Apr 2024 15:23:18 +0000 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [2a00:1450:4864:20::535]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 6b9d00d6-f817-11ee-b908-491648fe20b8; Thu, 11 Apr 2024 17:23:17 +0200 (CEST) Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-56c404da0ebso11890775a12.0 for ; Thu, 11 Apr 2024 08:23:16 -0700 (PDT) Received: from andrewcoop.citrite.net (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id fg5-20020a056402548500b0056c5515c183sm779639edb.13.2024.04.11.08.23.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 08:23:15 -0700 (PDT) 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" X-Inumbo-ID: 6b9d00d6-f817-11ee-b908-491648fe20b8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1712848996; x=1713453796; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Kvx5iWu0y4pMcC1rcy3iKy6ujT2KOD9cF1Frc/ddC/k=; b=jkGmBWYiCJTkrw1Dv0Fhyo1F4WFyOqZdqCaN8i5lOkwXMiUkYnsxD7KmhfDvj4/l35 GTldcakiftyG82Z/qZ1S4MoMGWC4nVx5d0KEoO+9sJboTWTGWolnjsYLUaL8GNoC0sxv cZBT2neIGc9H7+iedhA73pSiKU0NvQUHyrSms= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712848996; x=1713453796; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Kvx5iWu0y4pMcC1rcy3iKy6ujT2KOD9cF1Frc/ddC/k=; b=iek1u8ploGztEjWCMdEJ8iJxxePVxBopAcibIzfuExnF5I66cTCM3sd3gYzn3hTiD9 /MB8ih1zy/ZD0QaxRk/bt8cA6ihdV+3LjeOG1G6L92qfbxUYr/AY6RUdTYUzHJoPUpkE lKhFVy7bZv9eieUpYuyU7wWXWSpTOvIKybUFod3V0AsQnK2viMBOhVKwil11r8p8HJMs guyyFjARWoy4o4Pi9pSZ8VtwWjKH48BAInFIbhZVFMhFle73ZrbtsZy0fNqvoy/dGGO8 9Alet7H5+ZtNU4Vzdd5WhHPDSlKQE6DmOjzAiScsJTI0rzcxxmzQnX+9IVEOZL3CqHjf D9kA== X-Gm-Message-State: AOJu0Yw6iAJgElfRSJffx5GzZKaClZ7qq5JxnQvd4npaoiAc4RsyI7um nxu4b6BgsGUa/ZTgeS1FoWlAi1vlbBcUfAuswobjIpM02IUcW1xQFFmI7ve0hK7Y0QoDz4RPQ+B l5E8= X-Google-Smtp-Source: AGHT+IGA3qPPz8ulC9rAxmuThsDLUGs6jB3U1/OyvRy69tM+DhQAXGf/qEPIYgufZEqNAOl7ckwCSQ== X-Received: by 2002:a50:9f2b:0:b0:56e:2ebc:5c4 with SMTP id b40-20020a509f2b000000b0056e2ebc05c4mr76801edf.20.1712848996042; Thu, 11 Apr 2024 08:23:16 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH] x86/emul: Simplify segment override prefix decoding Date: Thu, 11 Apr 2024 16:23:14 +0100 Message-Id: <20240411152314.1755561-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1712849023851100001 x86_seg_* uses architectural encodings. Therefore, we can fold the prefix handling cases together and derive the segment from the prefix byte itself. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 This makes a marginal saving of 47 bytes, indicating (not unexpectedly) that the optimiser cannot fold the case statements automatically. fs/gs is weirder. The expression is 4 + (b & 1), and for some reason this adds +264 bytes to the function. Even if the logical expression is larger than two simple stores (and it probably is), it's not +264 bytes larger... --- xen/arch/x86/x86_emulate/decode.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/xen/arch/x86/x86_emulate/decode.c b/xen/arch/x86/x86_emulate/d= ecode.c index de836068fdd8..ee4cbdc0002c 100644 --- a/xen/arch/x86/x86_emulate/decode.c +++ b/xen/arch/x86/x86_emulate/decode.c @@ -1043,17 +1043,12 @@ int x86emul_decode(struct x86_emulate_state *s, case 0x67: /* address-size override */ ad_bytes =3D def_ad_bytes ^ (mode_64bit() ? 12 : 6); break; - case 0x2e: /* CS override / ignored in 64-bit mode */ + case 0x26: /* ES override */ + case 0x2e: /* CS override */ + case 0x36: /* SS override */ + case 0x3e: /* DS override, all ignored in 64-bit mode */ if ( !mode_64bit() ) - override_seg =3D x86_seg_cs; - break; - case 0x3e: /* DS override / ignored in 64-bit mode */ - if ( !mode_64bit() ) - override_seg =3D x86_seg_ds; - break; - case 0x26: /* ES override / ignored in 64-bit mode */ - if ( !mode_64bit() ) - override_seg =3D x86_seg_es; + override_seg =3D (b >> 3) & 3; break; case 0x64: /* FS override */ override_seg =3D x86_seg_fs; @@ -1061,10 +1056,6 @@ int x86emul_decode(struct x86_emulate_state *s, case 0x65: /* GS override */ override_seg =3D x86_seg_gs; break; - case 0x36: /* SS override / ignored in 64-bit mode */ - if ( !mode_64bit() ) - override_seg =3D x86_seg_ss; - break; case 0xf0: /* LOCK */ s->lock_prefix =3D true; break; --=20 2.30.2