RE: [PATCH v2 5/7] ACPI / x86: introduce acpi_os_readable() support

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

 



Hi, Yu

> From: Chen, Yu C
> Sent: Tuesday, November 10, 2015 5:43 PM
> 
> Hi, Lv
> Sorry for my late feedback on the patch, one minor nit below:
> 
> > From: Zheng, Lv
> > Sent: Tuesday, November 10, 2015 4:22 PM
> >
> > From: Chen Yu <yu.c.chen@xxxxxxxxx>
> >
> > This patch implements acpi_os_readable(). The function is used by ACPI AML
> > debugger to validate user specified pointers for the dumpable AML operand
> > objects.
> >
> > Signed-off-by: Chen Yu <yu.c.chen@xxxxxxxxx>
> > Signed-off-by: Lv Zheng <lv.zheng@xxxxxxxxx>
> > ---
> > +bool __acpi_memory_readable(void *pointer, size_t length) {
> > +	unsigned long start_pfn, end_pfn;
> > +
> We should only check the low memory, otherwise the highmem address might
> bring unexpected behavior in this function, I think we should add:
> 	if (pointer  >= PAGE_OFFSET)
> 		return false;

I think pfn_range_is_mapped() can ensure this.
If you want to add some sanity checks, IMO, virt_addr_valid() could be better.

> > +	start_pfn = page_to_pfn(virt_to_page(pointer));
> > +	end_pfn = page_to_pfn(virt_to_page(pointer + length));
> Convert pointer to char* first?
> end_pfn = page_to_pfn(virt_to_page((char*)pointer + length));

Either a compiler supports such a conversion or a compiler ends up fatal error by complaining unknown sizeof(void *).
So there is no need to do this here as the build test has passed.

Thanks and best regards
-Lv

> 
> > +	/*
> > +	 * Since the acpi address is allocated by kmalloc, we only
> > +	 * need to consider the direct-mapping virtual address,
> > +	 * rather than the kmap/vmalloc/ioremap address.
> > +	 */
> > +	return pfn_range_is_mapped(start_pfn, end_pfn) ? true : false; }
> > +
> Thanks!
> 
> Best Regards,
> Yu
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux