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

Re: [PATCH] AMD/IOMMU: drop remaining guest-IOMMU bits too


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 20 Mar 2024 11:58:50 +0100
  • Autocrypt: addr=jbeulich@xxxxxxxx; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • Delivery-date: Wed, 20 Mar 2024 10:58:55 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 20.03.2024 11:46, Roger Pau Monné wrote:
> On Tue, Mar 19, 2024 at 02:28:12PM +0100, Jan Beulich wrote:
>> With a02174c6c885 ("amd/iommu: clean up unused guest iommu related
>> functions") having removed the sole place where d->g_iommu would be set
>> to non-NULL, guest_iommu_add_ppr_log() will unconditionally bail the
>> latest from its 2nd if(). With it dropped, all other stuff in the file
>> is unused, too. Delete iommu_guest.c altogether.
>>
>> Further delete struct guest{_buffer,_dev_table,_iommu{,_msi}} as well as
>> struct mmio_reg for being unused with the unused g_iommu also dropped
>> from struct arch_iommu.
>>
>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
>> ---
>> I wasn't sure how far to further go with removing the body of
>> parse_ppr_log_entry(), or perhaps even the entire function, and then
>> further up to all PPR logging code. Hence why for now I've merely
>> commented out the function call into the file being deleted (which of
>> course Misra isn't going to like). Thoughts / suggestions?
>>
>> I further wonder whether set_iommu_guest_translation_control() should
>> have been invoked independent of guest-IOMMU actually being enabled. IOW
>> that may want purging, too. Along these lines iommuv2_enabled may also
>> want dropping, for not having any consumer left. Much like has_viommu()
>> and then also {XEN_,}X86_EMU_IOMMU, i.e. going as far as affecting the
>> public interface.
>>
>> --- a/xen/arch/x86/include/asm/iommu.h
>> +++ b/xen/arch/x86/include/asm/iommu.h
>> @@ -52,7 +52,6 @@ struct arch_iommu
>>          struct {
>>              unsigned int paging_mode;
>>              struct page_info *root_table;
>> -            struct guest_iommu *g_iommu;
>>          } amd;
>>      };
>>  };
>> --- a/xen/drivers/passthrough/amd/Makefile
>> +++ b/xen/drivers/passthrough/amd/Makefile
>> @@ -5,4 +5,3 @@ obj-y += pci_amd_iommu.o
>>  obj-bin-y += iommu_acpi.init.o
>>  obj-y += iommu_intr.o
>>  obj-y += iommu_cmd.o
>> -obj-$(CONFIG_HVM) += iommu_guest.o
>> --- a/xen/drivers/passthrough/amd/iommu.h
>> +++ b/xen/drivers/passthrough/amd/iommu.h
>> @@ -145,57 +145,6 @@ int iterate_ivrs_entries(int (*handler)(
>>                                          struct ivrs_mappings *map,
>>                                          uint16_t bdf));
>>  
>> -/* iommu tables in guest space */
>> -struct mmio_reg {
>> -    uint32_t    lo;
>> -    uint32_t    hi;
>> -};
>> -
>> -struct guest_dev_table {
>> -    struct mmio_reg         reg_base;
>> -    uint32_t                size;
>> -};
>> -
>> -struct guest_buffer {
>> -    struct mmio_reg         reg_base;
>> -    struct mmio_reg         reg_tail;
>> -    struct mmio_reg         reg_head;
>> -    uint32_t                size;
>> -};
>> -
>> -struct guest_iommu_msi {
>> -    uint8_t                 vector;
>> -    uint8_t                 dest;
>> -    uint8_t                 dest_mode;
>> -    uint8_t                 delivery_mode;
>> -    uint8_t                 trig_mode;
>> -};
>> -
>> -/* virtual IOMMU structure */
>> -struct guest_iommu {
>> -
>> -    struct domain          *domain;
>> -    spinlock_t              lock;
>> -    bool                    enabled;
>> -
>> -    struct guest_dev_table  dev_table;
>> -    struct guest_buffer     cmd_buffer;
>> -    struct guest_buffer     event_log;
>> -    struct guest_buffer     ppr_log;
>> -
>> -    struct tasklet          cmd_buffer_tasklet;
>> -
>> -    uint64_t                mmio_base;             /* MMIO base address */
>> -
>> -    /* MMIO regs */
>> -    union amd_iommu_control reg_ctrl;              /* MMIO offset 0018h */
>> -    struct mmio_reg         reg_status;            /* MMIO offset 2020h */
>> -    union amd_iommu_ext_features reg_ext_feature;  /* MMIO offset 0030h */
>> -
>> -    /* guest interrupt settings */
>> -    struct guest_iommu_msi  msi;
>> -};
>> -
>>  extern bool iommuv2_enabled;
> 
> I think iommuv2_enabled can also go away, since it's only used by
> guest_iommu_init()?
> 
> It's set in amd_iommu_prepare() and amd_iommu_init_cleanup() but only
> consumed by guest_iommu_init().

See the post-commit-message remarks: The main question is where to stop.

Jan



 


Rackspace

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