/* * The PASID_FLAG_FL5LP flag Indicates using 5-level paging for first- * level translation, otherwise, 4-level paging will be used.
*/ #define PASID_FLAG_FL5LP BIT(1)
/* The representative of a PASID table */ struct pasid_table { void *table; /* pasid table pointer */
u32 max_pasid; /* max pasid */
};
/* Get PRESENT bit of a PASID directory entry. */ staticinlinebool pasid_pde_is_present(struct pasid_dir_entry *pde)
{ return READ_ONCE(pde->val) & PASID_PTE_PRESENT;
}
/* Get PASID table from a PASID directory entry. */ staticinlinestruct pasid_entry *
get_pasid_table_from_pde(struct pasid_dir_entry *pde)
{ if (!pasid_pde_is_present(pde)) return NULL;
/* Get PRESENT bit of a PASID table entry. */ staticinlinebool pasid_pte_is_present(struct pasid_entry *pte)
{ return READ_ONCE(pte->val[0]) & PASID_PTE_PRESENT;
}
/* Get FPD(Fault Processing Disable) bit of a PASID table entry */ staticinlinebool pasid_pte_is_fault_disabled(struct pasid_entry *pte)
{ return READ_ONCE(pte->val[0]) & PASID_PTE_FPD;
}
/* Get PGTT field of a PASID table entry */ staticinline u16 pasid_pte_get_pgtt(struct pasid_entry *pte)
{ return (u16)((READ_ONCE(pte->val[0]) >> 6) & 0x7);
}
/* * Setup the DID(Domain Identifier) field (Bit 64~79) of scalable mode * PASID entry.
*/ staticinlinevoid
pasid_set_domain_id(struct pasid_entry *pe, u64 value)
{
pasid_set_bits(&pe->val[1], GENMASK_ULL(15, 0), value);
}
/* * Get domain ID value of a scalable mode PASID entry.
*/ staticinline u16
pasid_get_domain_id(struct pasid_entry *pe)
{ return (u16)(READ_ONCE(pe->val[1]) & GENMASK_ULL(15, 0));
}
/* * Setup the SLPTPTR(Second Level Page Table Pointer) field (Bit 12~63) * of a scalable mode PASID entry.
*/ staticinlinevoid
pasid_set_slptr(struct pasid_entry *pe, u64 value)
{
pasid_set_bits(&pe->val[0], VTD_PAGE_MASK, value);
}
/* * Setup the AW(Address Width) field (Bit 2~4) of a scalable mode PASID * entry.
*/ staticinlinevoid
pasid_set_address_width(struct pasid_entry *pe, u64 value)
{
pasid_set_bits(&pe->val[0], GENMASK_ULL(4, 2), value << 2);
}
/* * Setup the PGTT(PASID Granular Translation Type) field (Bit 6~8) * of a scalable mode PASID entry.
*/ staticinlinevoid
pasid_set_translation_type(struct pasid_entry *pe, u64 value)
{
pasid_set_bits(&pe->val[0], GENMASK_ULL(8, 6), value << 6);
}
/* * Enable fault processing by clearing the FPD(Fault Processing * Disable) field (Bit 1) of a scalable mode PASID entry.
*/ staticinlinevoid pasid_set_fault_enable(struct pasid_entry *pe)
{
pasid_set_bits(&pe->val[0], 1 << 1, 0);
}
/* * Enable second level A/D bits by setting the SLADE (Second Level * Access Dirty Enable) field (Bit 9) of a scalable mode PASID * entry.
*/ staticinlinevoid pasid_set_ssade(struct pasid_entry *pe)
{
pasid_set_bits(&pe->val[0], 1 << 9, 1 << 9);
}
/* * Disable second level A/D bits by clearing the SLADE (Second Level * Access Dirty Enable) field (Bit 9) of a scalable mode PASID * entry.
*/ staticinlinevoid pasid_clear_ssade(struct pasid_entry *pe)
{
pasid_set_bits(&pe->val[0], 1 << 9, 0);
}
/* * Checks if second level A/D bits specifically the SLADE (Second Level * Access Dirty Enable) field (Bit 9) of a scalable mode PASID * entry is set.
*/ staticinlinebool pasid_get_ssade(struct pasid_entry *pe)
{ return pasid_get_bits(&pe->val[0]) & (1 << 9);
}
/* * Setup the SRE(Supervisor Request Enable) field (Bit 128) of a * scalable mode PASID entry.
*/ staticinlinevoid pasid_set_sre(struct pasid_entry *pe)
{
pasid_set_bits(&pe->val[2], 1 << 0, 1);
}
/* * Setup the WPE(Write Protect Enable) field (Bit 132) of a * scalable mode PASID entry.
*/ staticinlinevoid pasid_set_wpe(struct pasid_entry *pe)
{
pasid_set_bits(&pe->val[2], 1 << 4, 1 << 4);
}
/* * Setup the P(Present) field (Bit 0) of a scalable mode PASID * entry.
*/ staticinlinevoid pasid_set_present(struct pasid_entry *pe)
{
pasid_set_bits(&pe->val[0], 1 << 0, 1);
}
/* * Setup Page Walk Snoop bit (Bit 87) of a scalable mode PASID * entry.
*/ staticinlinevoid pasid_set_page_snoop(struct pasid_entry *pe, bool value)
{
pasid_set_bits(&pe->val[1], 1 << 23, value << 23);
}
/* * Setup the Page Snoop (PGSNP) field (Bit 88) of a scalable mode * PASID entry.
*/ staticinlinevoid
pasid_set_pgsnp(struct pasid_entry *pe)
{
pasid_set_bits(&pe->val[1], 1ULL << 24, 1ULL << 24);
}
/* * Setup the First Level Page table Pointer field (Bit 140~191) * of a scalable mode PASID entry.
*/ staticinlinevoid
pasid_set_flptr(struct pasid_entry *pe, u64 value)
{
pasid_set_bits(&pe->val[2], VTD_PAGE_MASK, value);
}
/* * Setup the First Level Paging Mode field (Bit 130~131) of a * scalable mode PASID entry.
*/ staticinlinevoid
pasid_set_flpm(struct pasid_entry *pe, u64 value)
{
pasid_set_bits(&pe->val[2], GENMASK_ULL(3, 2), value << 2);
}
/* * Setup the Extended Access Flag Enable (EAFE) field (Bit 135) * of a scalable mode PASID entry.
*/ staticinlinevoid pasid_set_eafe(struct pasid_entry *pe)
{
pasid_set_bits(&pe->val[2], 1 << 7, 1 << 7);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.