kernel defines typedef struct { unsigned long long pgd; } pgd_t; but what I know is it should eb an array depending on how you haev broken up the virtual address. how that table is created ?
>>> typedef struct { unsigned long long pgd; } pgd_t;
pgd_t is used to reference a single entry in the PGD. For example:
pgd_t *pgd; int pgd_idx; pgd_idx = pgd_index(address); pgd = pgd_base + pgd_idx;
About PGD creation (arch/x86/mm/pgtable_32.c):
pgd_t *pgd_alloc(struct mm_struct *mm) { int i; pgd_t *pgd = quicklist_alloc(0, GFP_KERNEL, pgd_ctor); if (PTRS_PER_PMD == 1 || !pgd) return pgd;
quicklist_alloc takes a page and calls pgd_ctor to build PGD.
Page global directory
>>> typedef struct { unsigned long long pgd; } pgd_t;
pgd_t is used to reference a single entry in the PGD. For example:
pgd_t *pgd;
int pgd_idx;
pgd_idx = pgd_index(address);
pgd = pgd_base + pgd_idx;
About PGD creation (arch/x86/mm/pgtable_32.c):
pgd_t *pgd_alloc(struct mm_struct *mm)
{
int i;
pgd_t *pgd = quicklist_alloc(0, GFP_KERNEL, pgd_ctor);
if (PTRS_PER_PMD == 1 || !pgd)
return pgd;
quicklist_alloc takes a page and calls pgd_ctor to build PGD.