From nobody Thu Nov 21 19:24:01 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=cloud.com ARC-Seal: i=1; a=rsa-sha256; t=1723045240; cv=none; d=zohomail.com; s=zohoarc; b=GuUru+En1WxIyOoxalPv6SQNL0q+bPpSpRBOCJCsa2hBpzvNdnxs1LV5Tcy3kI/OofVG2y9jIYohRKqGKZ96WBVxGeUj0LMxoJdvNMooA8hRuQbgNdFJ6Ni5dxkl8JR410RUekI++boBPWQk/5ujKFtHRvj2SAPEAm/Z4f56Lpo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723045240; h=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=UmDI4Dz84kXGt5jmXeHADz7wjjK1TvXqao2udkFRzFU=; b=h17J7J/ohik0bi8d1pIslUFtLw55aWuoXk4fp7syO7pVb1XFxv39vZn75pIBPPOJWIELWi6WJBEdus24WSmcKfEx6IsLjlx4P//o3WS5p1ZDHAAe5F/+csjdFAJzKn7ujRj2yea2KnFSUU98ErOxb5dFOaICxoeE52Gr+IcGKz8= 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 1723045240220315.2696965434707; Wed, 7 Aug 2024 08:40:40 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.773594.1184030 (Exim 4.92) (envelope-from ) id 1sbilZ-00037H-66; Wed, 07 Aug 2024 15:39:57 +0000 Received: by outflank-mailman (output) from mailman id 773594.1184030; Wed, 07 Aug 2024 15:39:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sbilZ-00037A-34; Wed, 07 Aug 2024 15:39:57 +0000 Received: by outflank-mailman (input) for mailman id 773594; Wed, 07 Aug 2024 15:39:56 +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 1sbilY-00036l-09 for xen-devel@lists.xenproject.org; Wed, 07 Aug 2024 15:39:56 +0000 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [2a00:1450:4864:20::632]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4a8069d7-54d3-11ef-8776-851b0ebba9a2; Wed, 07 Aug 2024 17:39:53 +0200 (CEST) Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-a7aada2358fso178978566b.0 for ; Wed, 07 Aug 2024 08:39:53 -0700 (PDT) Received: from EMEAENGAAD91498.citrite.net ([217.156.233.154]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7dc9e83848sm659353366b.177.2024.08.07.08.39.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Aug 2024 08:39:52 -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: 4a8069d7-54d3-11ef-8776-851b0ebba9a2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1723045193; x=1723649993; 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=UmDI4Dz84kXGt5jmXeHADz7wjjK1TvXqao2udkFRzFU=; b=YYik4yjS/jkj//IfceODnxa+oj6GzRXk9nO6hMy2p80/aNshYoSbpITJnMHdAqQyOS /lRpMQF3jIUhWtcCHLhc0AsgYd3MJ09zVItZK1uCKcwprmnuL1wb+nio4JCzr2eZeznL n9fqp/9NzknGjC6/y50/5ofoHXjAGRYKK5Am4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723045193; x=1723649993; 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=UmDI4Dz84kXGt5jmXeHADz7wjjK1TvXqao2udkFRzFU=; b=LYP7qBWj2xAJ2YGQ5wS4bolIZ/NB/ltbdCEczaUg0M+XUgH1Cp6fFHFr7gske6d6ba KyhkGFF7djhSoI2ShqrednTWakjsUxrV8MynuoOcJhL/l/OFqbQRazJ9eZOyU2vuWP1W 6V75nqx1xVq/ffN3h22pL0VDr2rZh7KzQ4Kxbij1FVUsHiXZzB8iUfzQk05u3vY2pD1T Q9CntFndaKIJtAc1GBGzX5ao3NSUHqvGKToFJFqw6zvVwIoz7ypVnWV40CUpsToJSY9x u4wqLborApT1cKg8BeKkdxU+aseLLcDWhVOI3s501DnQkskps4p55ra3wAjpHe/YpiYU PV8A== X-Gm-Message-State: AOJu0YzMgS6YEcug7l0xCXlSmFC2HIdqo7cC9ilZ3NBo7eu261LRadyg EaUrdbiOTs/xcCBrg75sfQH45ke/Al0TNT2hkBQI9TJ2inL+FkybIQhMIU061DbDb3+4DPOHuH5 P X-Google-Smtp-Source: AGHT+IHUaiC7CK6CdZ199QZAgPkzDI8L6GWOCXVbHNwek8ATHbDzH//F+Chui1fY3ZszYHvOcl2DaA== X-Received: by 2002:a17:906:dc8f:b0:a7d:88c4:2897 with SMTP id a640c23a62f3a-a8078fef41cmr230132166b.2.1723045192458; Wed, 07 Aug 2024 08:39:52 -0700 (PDT) From: Matthew Barnes To: Xen-devel Cc: Matthew Barnes , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [XEN PATCH v2] x86/emul: Fix misaligned IO breakpoint behaviour in PV guests Date: Wed, 7 Aug 2024 16:39:37 +0100 Message-Id: <4219d12fcd075635c8c2548c5d14471642af3038.1723045077.git.matthew.barnes@cloud.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Bcc: Matthew Barnes Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1723045241968116600 Content-Type: text/plain; charset="utf-8" When hardware breakpoints are configured on misaligned IO ports, the hardware will mask the addresses based on the breakpoint width during comparison. For PV guests, misaligned IO breakpoints do not behave the same way, and therefore yield different results. This patch tweaks the emulation of IO breakpoints for PV guests such that they reproduce the same behaviour as hardware. Fixes: bec9e3205018 ("x86: emulate I/O port access breakpoints") Signed-off-by: Matthew Barnes Reviewed-by: Jan Beulich --- Changes in v2: - Refactor breakpoint port masking to be more succinct - Add 'Fixes' line to commit message --- xen/arch/x86/pv/emul-priv-op.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/arch/x86/pv/emul-priv-op.c b/xen/arch/x86/pv/emul-priv-op.c index f101510a1bab..aa11ecadaac0 100644 --- a/xen/arch/x86/pv/emul-priv-op.c +++ b/xen/arch/x86/pv/emul-priv-op.c @@ -346,6 +346,8 @@ static unsigned int check_guest_io_breakpoint(struct vc= pu *v, case DR_LEN_8: width =3D 8; break; } =20 + start &=3D ~(width - 1UL); + if ( (start < (port + len)) && ((start + width) > port) ) match |=3D 1u << i; } --=20 2.34.1