Re: Why exported const value modified by another driver not updated in original driver

2012-09-05 Thread Manavendra Nath Manav
On Tue, Sep 4, 2012 at 5:55 PM, Dan Carpenter dan.carpen...@oracle.com wrote:
 On Tue, Sep 04, 2012 at 03:58:20PM +0530, Manavendra Nath Manav wrote:
 Is the above a genuine kernel bug, or i am missing something out here. Pls 
 help.


 When you declare something as const then the compiler assumes it
 really is const and uses a literal instead of reading from memory.
 I'm surprised the compiler doesn't print a warning message.

 It has to do with compilers, nothing to do with kernels.

 regards,
 dan carpenter

Thanks All,
I understood the problem and current gcc behaviour after looking at
output of objdump of driver.ko file when the variable is declared as
const and in second case as const volatile. The compiler optimises
by directly passing the value in first case and the address of
variable in second case. Thanks for all the help and clarification.

push   $0x7b // 123 in decimal
push   $0x0

-- 
Manavendra Nath Manav

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Why __force sparse annotation needed in copy_from_user() to vmalloc'ed area

2012-09-05 Thread Thomas Petazzoni
Hello,

In the course of reviewing a new framebuffer driver [1], I discovered
the following bit of code:

+   dst = (void __force *) (info-screen_base + p);
+
+   if (copy_from_user(dst, buf, count))
+   err = -EFAULT;

Where info-screen_base is a vmalloc'ed memory area. Many other
framebuffer drivers have used this __force sparse annotation: see [2]
or [3] for example.

I am confused as to why sparse requires the __force annotation for what
seems to be a regular user to kernel copy. The __force annotation is
typically not needed for user to kernel copy when the destination
kernel buffer has been kmalloc'ed.

Why does sparse handles vmalloc'ed buffer differently, and gives a
warning in this case?

Thanks,

Thomas

[1] http://marc.info/?l=linux-fbdevm=134683775709128w=2
[2] 
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=28cdf76bf0bce757428f84161e3aa510028d47b4
[3] 
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=d2e8d369cd92a8bb856ff530fa1e4c03b0e0ff55
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


module loading issue module_layout

2012-09-05 Thread Kshemendra KP
Hi
 As the kernel source not available for running kernel  code of an
Andodiod tablet,
I could not able to match module_layout address of my loadable module with
the
 android tablet running kernel even the kernel versions are same.

Is there a way to generate build environment in such a situation as
the manufacture source is bit deviated from source he has posted on  the
net.

Regards
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: module loading issue module_layout

2012-09-05 Thread Mulyadi Santosa
On Wed, Sep 5, 2012 at 7:04 PM, Kshemendra KP kshemen...@suphalaam.com wrote:
 Is there a way to generate build environment in such a situation as
 the manufacture source is bit deviated from source he has posted on  the
 net.

a friend of mine said, you should just use Android SDK. But I am not
sure whether that also applies to kernel space.
-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Places where the kernel modifies itself (.text) during runtime

2012-09-05 Thread Andrew Case
Hello,

I am trying to determine all the ways/methods in which the kernel will
modify its own .text section after the machine has booted. I am
working with the latest Fedora kernel (3.5.2-3.fc17.x86_64).

So far I have identified:

1) smp_locks
2) .alt_instructions - although from writing a script to parse the
alt_instr structures, it seems these may not affect .text, any
clarification on this would be greatly appreciated.
3) dynamic ftracing (related to mcount)

4)
I also see where the paravirt instructions (PVOP_CALL4) seems to
compile as absolute call instructions, but then become relative calls
at runtime. I figured this one out this by diffing the disassembly of
xen_cpuid_base in both memory and from the vmlinux after noticing they
were not the same:

# diff xen_cpuid_base-memory xen_cpuid_base-disk
20,21c20
 003C  E8A2E5A3FFcall dword 0xffa3e5e3
 0041  6690  xchg ax,ax
---
 003C  FF142580DCC181call qword [0x81c1dc80]

and the 0x81c1dc80 instruction relates to the cpuid function
which ends up in paravirt code.

Any clarifications or links to docs on this changing of the calls in
the paravirt subsystem would be helpful.

I also would like to find out if the kernel changes itself in any
other way besides those that I have listed.

Thanks,
Andrew

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Places where the kernel modifies itself (.text) during runtime

2012-09-05 Thread Mulyadi Santosa
Hi Andrew...

On Thu, Sep 6, 2012 at 2:56 AM, Andrew Case atc...@gmail.com wrote:
 So far I have identified:

 1) smp_locks
 2) .alt_instructions - although from writing a script to parse the
 alt_instr structures, it seems these may not affect .text, any
 clarification on this would be greatly appreciated.
 3) dynamic ftracing (related to mcount)

 4)
 I also see where the paravirt instructions (PVOP_CALL4) seems to
 compile as absolute call instructions, but then become relative calls
 at runtime.

maybe also kprobe and dynamic printk

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies