elf2dmp: Rename PAGE_SIZE to ELF2DMP_PAGE_SIZE
As per POSIX specification of limits.h [1], OS libc may define PAGE_SIZE in limits.h. To prevent collosion of definition, we rename PAGE_SIZE here. [1]: https://pubs.opengroup.org/onlinepubs/7908799/xsh/limits.h.html Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20210118063808.12471-6-jiaxun.yang@flygoat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
		
							parent
							
								
									9c57272507
								
							
						
					
					
						commit
						2d0fc797fa
					
				@ -207,8 +207,8 @@ int va_space_rw(struct va_space *vs, uint64_t addr,
 | 
				
			|||||||
        void *buf, size_t size, int is_write)
 | 
					        void *buf, size_t size, int is_write)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    while (size) {
 | 
					    while (size) {
 | 
				
			||||||
        uint64_t page = addr & PFN_MASK;
 | 
					        uint64_t page = addr & ELF2DMP_PFN_MASK;
 | 
				
			||||||
        size_t s = (page + PAGE_SIZE) - addr;
 | 
					        size_t s = (page + ELF2DMP_PAGE_SIZE) - addr;
 | 
				
			||||||
        void *ptr;
 | 
					        void *ptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        s = (s > size) ? size : s;
 | 
					        s = (s > size) ? size : s;
 | 
				
			||||||
 | 
				
			|||||||
@ -10,9 +10,9 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "qemu_elf.h"
 | 
					#include "qemu_elf.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define PAGE_BITS 12
 | 
					#define ELF2DMP_PAGE_BITS 12
 | 
				
			||||||
#define PAGE_SIZE (1ULL << PAGE_BITS)
 | 
					#define ELF2DMP_PAGE_SIZE (1ULL << ELF2DMP_PAGE_BITS)
 | 
				
			||||||
#define PFN_MASK (~(PAGE_SIZE - 1))
 | 
					#define ELF2DMP_PFN_MASK (~(ELF2DMP_PAGE_SIZE - 1))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define INVALID_PA  UINT64_MAX
 | 
					#define INVALID_PA  UINT64_MAX
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -244,8 +244,8 @@ static int fill_header(WinDumpHeader64 *hdr, struct pa_space *ps,
 | 
				
			|||||||
    WinDumpHeader64 h;
 | 
					    WinDumpHeader64 h;
 | 
				
			||||||
    size_t i;
 | 
					    size_t i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QEMU_BUILD_BUG_ON(KUSD_OFFSET_SUITE_MASK >= PAGE_SIZE);
 | 
					    QEMU_BUILD_BUG_ON(KUSD_OFFSET_SUITE_MASK >= ELF2DMP_PAGE_SIZE);
 | 
				
			||||||
    QEMU_BUILD_BUG_ON(KUSD_OFFSET_PRODUCT_TYPE >= PAGE_SIZE);
 | 
					    QEMU_BUILD_BUG_ON(KUSD_OFFSET_PRODUCT_TYPE >= ELF2DMP_PAGE_SIZE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!suite_mask || !product_type) {
 | 
					    if (!suite_mask || !product_type) {
 | 
				
			||||||
        return 1;
 | 
					        return 1;
 | 
				
			||||||
@ -281,14 +281,14 @@ static int fill_header(WinDumpHeader64 *hdr, struct pa_space *ps,
 | 
				
			|||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (i = 0; i < ps->block_nr; i++) {
 | 
					    for (i = 0; i < ps->block_nr; i++) {
 | 
				
			||||||
        h.PhysicalMemoryBlock.NumberOfPages += ps->block[i].size / PAGE_SIZE;
 | 
					        h.PhysicalMemoryBlock.NumberOfPages += ps->block[i].size / ELF2DMP_PAGE_SIZE;
 | 
				
			||||||
        h.PhysicalMemoryBlock.Run[i] = (WinDumpPhyMemRun64) {
 | 
					        h.PhysicalMemoryBlock.Run[i] = (WinDumpPhyMemRun64) {
 | 
				
			||||||
            .BasePage = ps->block[i].paddr / PAGE_SIZE,
 | 
					            .BasePage = ps->block[i].paddr / ELF2DMP_PAGE_SIZE,
 | 
				
			||||||
            .PageCount = ps->block[i].size / PAGE_SIZE,
 | 
					            .PageCount = ps->block[i].size / ELF2DMP_PAGE_SIZE,
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    h.RequiredDumpSpace += h.PhysicalMemoryBlock.NumberOfPages << PAGE_BITS;
 | 
					    h.RequiredDumpSpace += h.PhysicalMemoryBlock.NumberOfPages << ELF2DMP_PAGE_BITS;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    *hdr = h;
 | 
					    *hdr = h;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -379,7 +379,7 @@ static int pe_get_pdb_symstore_hash(uint64_t base, void *start_addr,
 | 
				
			|||||||
    size_t pdb_name_sz;
 | 
					    size_t pdb_name_sz;
 | 
				
			||||||
    size_t i;
 | 
					    size_t i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QEMU_BUILD_BUG_ON(sizeof(*dos_hdr) >= PAGE_SIZE);
 | 
					    QEMU_BUILD_BUG_ON(sizeof(*dos_hdr) >= ELF2DMP_PAGE_SIZE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (memcmp(&dos_hdr->e_magic, e_magic, sizeof(e_magic))) {
 | 
					    if (memcmp(&dos_hdr->e_magic, e_magic, sizeof(e_magic))) {
 | 
				
			||||||
        return 1;
 | 
					        return 1;
 | 
				
			||||||
@ -509,10 +509,10 @@ int main(int argc, char *argv[])
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    printf("CPU #0 IDT[0] -> 0x%016"PRIx64"\n", idt_desc_addr(first_idt_desc));
 | 
					    printf("CPU #0 IDT[0] -> 0x%016"PRIx64"\n", idt_desc_addr(first_idt_desc));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    KernBase = idt_desc_addr(first_idt_desc) & ~(PAGE_SIZE - 1);
 | 
					    KernBase = idt_desc_addr(first_idt_desc) & ~(ELF2DMP_PAGE_SIZE - 1);
 | 
				
			||||||
    printf("Searching kernel downwards from 0x%016"PRIx64"...\n", KernBase);
 | 
					    printf("Searching kernel downwards from 0x%016"PRIx64"...\n", KernBase);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (; KernBase >= 0xfffff78000000000; KernBase -= PAGE_SIZE) {
 | 
					    for (; KernBase >= 0xfffff78000000000; KernBase -= ELF2DMP_PAGE_SIZE) {
 | 
				
			||||||
        nt_start_addr = va_space_resolve(&vs, KernBase);
 | 
					        nt_start_addr = va_space_resolve(&vs, KernBase);
 | 
				
			||||||
        if (!nt_start_addr) {
 | 
					        if (!nt_start_addr) {
 | 
				
			||||||
            continue;
 | 
					            continue;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user