Re: Return value for "impossible" situations

2021-07-25 Thread Ian Pilcher
On 7/25/21 6:15 PM, Valdis Klētnieks wrote: The *proper* thing to do is, instead of deciding to return -EHIT_A_BUG, do a WARN(), or BUG(), so that the dmesg has something that's at least potentially useful. Then use that information to fix the issue. The question is, after the WARN_ON, what co

Re: How can I convert user virtual address to kernel virtual address and then to physical address?

2021-07-25 Thread Raghuram Jallipalli
Pls see if this helps https://linux-kernel-labs.github.io/refs/heads/master/labs/memory_mapping.html -Raghu On Sun, Jul 25, 2021, 10:16 PM wrote: > Hi, all, > > > > I’m testing a simple character driver on qemu arm64 virtual machine. > > I have uint64_t args[32] array and I pass args to the io

How can I convert user virtual address to kernel virtual address and then to physical address?

2021-07-25 Thread ckim
Hi, all, I'm testing a simple character driver on qemu arm64 virtual machine. I have uint64_t args[32] array and I pass args to the ioctl data. By the way args[2] contains the address of test_val which is set to 77. I want to change this value to 78 in the driver using kernel virtual address

Re: Return value for "impossible" situations

2021-07-25 Thread Valdis Klētnieks
On Sun, 25 Jul 2021 13:07:21 -0500, Ian Pilcher said: > Is there any sort of convention around what to return in the case of an > error in the logic of the code itself, something that will make it as > obvious as possible that the problem is a bug. In general, there's no good way to signal such i

Re: Return value for "impossible" situations

2021-07-25 Thread Bernd Petrovitsch
Hi all! On 25/07/2021 20:07, Ian Pilcher wrote: [...] > For kernel code, I can use pr_err, dump_stack, WARN_ON, etc. to report > the issue in the log, but I often also need to return some sort of error > code (negative errno value). This value goes up to userspace (otherwise it makes no real sens

Re: Return value for "impossible" situations

2021-07-25 Thread Ian Pilcher
On 7/25/21 1:59 PM, Bernd Petrovitsch wrote: This value goes up to userspace (otherwise it makes no real sense to use errno-values). Yes. I know that. That depends on the situation/sys-call/ You habe to choose the value (the list and short explanation is in `man errno`) which leads the u

Return value for "impossible" situations

2021-07-25 Thread Ian Pilcher
In user space, I use assertions to check (and document) the assumptions built in to my code - this value won't ever be negative, this int will only ever by one of these 3 values, etc. For kernel code, I can use pr_err, dump_stack, WARN_ON, etc. to report the issue in the log, but I often also nee