|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v2 06/17] xen/riscv: add root page table allocation
On 6/30/25 5:22 PM, Jan Beulich wrote:
On 10.06.2025 15:05, Oleksii Kurochko wrote: Yes, with the current one implementation, I agree it would be enough only root. But as you noticed below... And such re-creation is apparently infrequent, if happening at all after initial allocation. (But of course I don't know what future patches of yours will bring.) This is even more so if ...--- a/xen/arch/riscv/include/asm/riscv_encoding.h +++ b/xen/arch/riscv/include/asm/riscv_encoding.h @@ -133,11 +133,13 @@ #define HGATP_MODE_SV48X4 _UL(9) #define HGATP32_MODE_SHIFT 31 +#define HGATP32_MODE_MASK _UL(0x80000000) #define HGATP32_VMID_SHIFT 22 #define HGATP32_VMID_MASK _UL(0x1FC00000) #define HGATP32_PPN _UL(0x003FFFFF) #define HGATP64_MODE_SHIFT 60 +#define HGATP64_MODE_MASK _ULL(0xF000000000000000) #define HGATP64_VMID_SHIFT 44 #define HGATP64_VMID_MASK _ULL(0x03FFF00000000000)... VMID management is going to change as previously discussed, at which point the value to put in hgatp will need (partly) re-calculating at certain points anyway. ... after VMID management will changed to per-CPU base then it will be needed to update re-calculate hgatp each time vCPU on pCPU is changed. In this case I prefer to have partially calculated 'hgatp'.
You're right, the current name
The clean must follow the clear — so yes, the order needs to be reversed.
No any specific reason, I just decided not to introduce new definition as it is going to be used only inside this function. I think it will make sense to have in p2m.c: #define P2M_ROOT_PT_SIZE KB(16) If it isn't the best one option, then what about to move this defintion to config.h or asm/p2m.h. + unsigned int nr_pages = _AC(1,U) << order;Nit (style): Missing blank after comma. I've changed that to BIT(order, U)
It makes sense in this case just to return NULL. Further, to me the use of "more" looks misleading here. Do you perhaps mean "larger" or "bigger"? This also looks to be happening without any lock held. If that's intentional, I think the "why" wants clarifying in a code comment. Agree, returning back pages necessary for p2m root table should be done under spin_lock(&d->arch.paging.lock).
I thought it would be enough the comment above: /* Return back nr_pages necessary for p2m root table. */ + /* Allocate memory for p2m root table. */ + + /* + * As mentioned in the Priviliged Architecture Spec (version 20240411) + * As explained in Section 18.5.1, for the paged virtual-memory schemesThe first sentence didn't finish when the 2nd starts. Is there a piece missing? Do the two sentences want to be joined together? Nothing is missed, just bad wording. I will update to: As mentioned in the Priviliged Architecture Spec (version 20240411) in Section 18.5.1, ... +static unsigned long hgatp_from_page(struct p2m_domain *p2m)Function name and parameter type/name don't fit together. I'll update an argument to struct page_info *root.
No, it will be just passed as an argument. + unsigned long ppn; + unsigned long hgatp_mode; + + ppn = PFN_DOWN(page_to_maddr(p2m_root_page)) & HGATP_PPN; + +#if RV_STAGE1_MODE == SATP_MODE_SV39 + hgatp_mode = HGATP_MODE_SV39X4; +#elif RV_STAGE1_MODE == SATP_MODE_SV48 + hgatp_mode = HGATP_MODE_SV48X4; +#else +# error "add HGATP_MODE" +#endif + + return ppn | MASK_INSR(p2m->vmid, HGATP_VMID_MASK) | + MASK_INSR(hgatp_mode, HGATP_MODE_MASK); +} + +static int p2m_alloc_root_table(struct domain *d)As indicated earlier, in a wider context - this is a good candidate where the caller rather wants to pass struct p2m_domain *. Once you get variations on P2Ms (like x86'es altp2m or nestedp2m, the domain won't be meaningful here to know which P2M to allocate the root for. Good point. I will re-work that.
I am not really get your question. "wait" here is about the initialization of the pool which happens above this comment. + * table so that the necessary pages can be returned from the p2m pool, + * since the root table must be allocated using alloc_domheap_pages(...) + * to meet its specific requirements. + */ + if ( !d->arch.p2m.root )Aren't you open-coding p2m_get_hostp2m() here? Yes, p2m_get_hostp2m() should be used here. ~ Oleksii
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |