[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XEN][PATCH] x86: hvm: vlapic: rework WR/rsvdz masks for LVTx regs


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • Date: Thu, 9 Oct 2025 18:21:21 +0300
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mdDy8jsC70QrUES5frGDpRuKUOU90x3l6nrHViWL/fU=; b=tmv/WgLobA9Kp6qSBPAG8VQAwafZcd8YuOs8jROgee8UqS7uNEjg0fBfPV1ETz1CsDfx+xlQIhRxV/UA2hkgwMH/wy0yCVA8ESiWjqMhuQ6EkUgL1ySW2JxUJsFqwu1+yMxEBaTt8mQvaB8NVyf3HpDrAUkKfUQ4gzx1L1Su3+2qtjmlzDkEEAs+bVs25vO0zPjulaIagvuVL6OCm6QvCNf2X2mPA8RgnDO+ZHkWDR/SjNC8ISfhPfN88SVQPNXUPmCUWAQID59ynfR3gIN3Qs8ShOFJwRIEqmWJj/k9vm3eEBY8Pv5Q2XW0o7HqjSUkOhwf/fiV6lLBEPOrJXI2CA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FHiq5x/qavxRGiSJqHYMbxJBpV35ggnbR2gHBRA+YUaoRRdWqPRQVhPhtMDeTEAXFLWETzXt1Ayr7pzCetJXufsyQ+9Pxh/qXtSZKc+UsDuuvyFPHM7M4vcdG9Ec39OryWeqToFYc5Lt0iouukMyeT5xQKVzVxQfmFhj5SF5DMhQ9Nbx6w6I74ofqTQ/o0oI1cKZrCCgfsThna3lKdQbYIOKjfS+3HMkHkPjluPIdoE7yOFpq6UR9wWjoV3hgT21pj2wmMPcGsKXyEzWWe2Mui7WnTSsknPS5fyeEYip7DDMvd27AjnJmnP8PSFKlMBmral2MLL5EnL/fk2IOWbYJw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>, Jason Andryuk <jason.andryuk@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 09 Oct 2025 15:21:34 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Jan,

On 09.10.25 15:01, Jan Beulich wrote:
On 09.10.2025 13:42, Grygorii Strashko wrote:
From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>

Rework LVTx registers masks usage in MMIO/WRMSR write emulation code:

- do LVTx masks renaming and rearranging to x_WR_MASK/x_RO_MASK

- rename "vlapic_lvt_mask[]" to "lvt_wr_masks[]" to indicate they define
writable LVTx regs bits

- add lvt_rsvdz_masks[] and use it in guest_wrmsr_x2apic() for "Reserved"
bits checking (RsvdZ, Non-zero writes to reserved bits should cause #GP
exception)

Didn't we agree that this may better be done in two steps?

Huh, sorry for misunderstanding.


- add LVT_REG_IDX() macro to avoid open coding calculation of LVTx regs
indexes for lvt_wr_masks[]/lvt_rsvdz_masks[] in many places

Signed-off-by: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
---
Hi

Patch created according to discussion [1] and based on [1].

I've seen patches from Jan [2] a bit late, so sending
it as is for now.

Just wanted to ask, not the least because I'm increasingly of the opinion
that putting your fix on top of that series might end up being better.
For example, the special treatment of APIC_CMCI then shouldn't be needed
anymore.

not sure what to answer here


@@ -881,7 +898,7 @@ void vlapic_reg_write(struct vcpu *v, unsigned int reg, 
uint32_t val)
      case APIC_LVTERR:       /* LVT Error Reg */
          if ( vlapic_sw_disabled(vlapic) )
              val |= APIC_LVT_MASKED;
-        val &= array_access_nospec(vlapic_lvt_mask, (reg - APIC_LVTT) >> 4);
+        val &= array_access_nospec(lvt_wr_masks, LVT_REG_IDX(reg));

Just like it's here, ...

@@ -1013,26 +1030,18 @@ int guest_wrmsr_x2apic(struct vcpu *v, uint32_t msr, 
uint64_t val)
              return X86EMUL_EXCEPTION;
          break;
- case APIC_LVTT:
-        if ( val & ~(LVT_MASK | APIC_TIMER_MODE_MASK) )
+    case APIC_CMCI:
+        if ( val & ~(LVT_WR_MASK | LVT_RO_MASK | APIC_DM_MASK) )
              return X86EMUL_EXCEPTION;
          break;
+ case APIC_LVTT:
      case APIC_LVTTHMR:
      case APIC_LVTPC:
-    case APIC_CMCI:
-        if ( val & ~(LVT_MASK | APIC_DM_MASK) )
-            return X86EMUL_EXCEPTION;
-        break;
-
      case APIC_LVT0:
      case APIC_LVT1:
-        if ( val & ~LINT_MASK )
-            return X86EMUL_EXCEPTION;
-        break;
-
      case APIC_LVTERR:
-        if ( val & ~LVT_MASK )
+        if ( val & lvt_rsvdz_masks[LVT_REG_IDX(offset)] )

... array_access_nospec() also needs using here.

ok


--
Best regards,
-grygorii




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.