It will be very useful for user space (QEMU/KVMTOOL) if it has a
method of querying VCPU target type matching to underlying Host.
We can use such querying mechanism and implement machine models
in user space where VCPU target type is always same-as/similar-to
underlying Host (i.e. Target CPU=Host).
This patch series implements KVM_ARM_PREFERRED_TARGET vm ioclt for
querying VCPU target type matching underlying host. Using this new
ioctl we can implement VCPU target CPU=Host in user space.
Also, it is not mandatory to call KVM_ARM_PREFERRED_TARGET vm ioctl
and the old method of trying all possible target types using the
KVM_ARM_VCPU_INIT ioctl to initialize VCPU works fine.
V5:
- Update documentation based on review comments
V4:
- Fixed files exchanged between patches
- For now return zeroed features in struct kvm_vcpu_init instance
V3:
- Return -ENODEV if no preferred target available for host
- Make KVM_ARM_PREFERRED_TARGET ioctl as vm ioctl
V2:
- Renamed the ioclt to KVM_ARM_PREFERRED_TARGET
- Return struct kvm_vcpu_init instace instead of just target type
V1:
- Initial patch-set with ioctl named as KVM_ARM_SUITABLE_TARGET
Anup Patel (4):
ARM: KVM: Implement kvm_vcpu_preferred_target() function
ARM64: KVM: Implement kvm_vcpu_preferred_target() function
ARM/ARM64: KVM: Implement KVM_ARM_PREFERRED_TARGET ioctl
KVM: Add documentation for KVM_ARM_PREFERRED_TARGET ioctl
Documentation/virtual/kvm/api.txt | 31 +++++++++++++++++++++++++++----
arch/arm/include/asm/kvm_host.h | 1 +
arch/arm/kvm/arm.c | 13 +++++++++++++
arch/arm/kvm/guest.c | 20 ++++++++++++++++++++
arch/arm64/include/asm/kvm_host.h | 1 +
arch/arm64/kvm/guest.c | 20 ++++++++++++++++++++
include/uapi/linux/kvm.h | 1 +
7 files changed, 83 insertions(+), 4 deletions(-)
--
1.7.9.5
In ftrace_syscall_enter(),
syscall_get_arguments(..., 0, n, ...)
if (i == 0) { <handle orig_x0> ...; n--;}
memcpy(..., n * sizeof(args[0]));
If 'number of arguments(n)' is zero and 'argument index(i)' is also zero in
syscall_get_arguments(), none of arguments should be copied by memcpy().
Otherwise 'n--' can be a big positive number and unexpected amount of data
will be copied. Tracing system calls which take no argument, say sync(void),
may hit this case and eventually make the system corrupted.
This patch fixes the issue both in syscall_get_arguments() and
syscall_set_arguments().
Please note, however, that asm-generic/syscall.h says,
* syscall_get_arguments - extract system call parameter values
* @i: argument index [0,5]
* @n: number of arguments; n+i must be [1,6].
and so we'd better change the caller's code(ftrace_syscall_enter).
Signed-off-by: AKASHI Takahiro <takahiro.akashi(a)linaro.org>
---
arch/arm64/include/asm/syscall.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/syscall.h
index c89821f..01bb8cc 100644
--- a/arch/arm64/include/asm/syscall.h
+++ b/arch/arm64/include/asm/syscall.h
@@ -63,6 +63,9 @@ static inline void syscall_get_arguments(struct task_struct *task,
unsigned int i, unsigned int n,
unsigned long *args)
{
+ if (n == 0)
+ return;
+
if (i + n > SYSCALL_MAX_ARGS) {
unsigned long *args_bad = args + SYSCALL_MAX_ARGS - i;
unsigned int n_bad = n + i - SYSCALL_MAX_ARGS;
@@ -86,6 +89,9 @@ static inline void syscall_set_arguments(struct task_struct *task,
unsigned int i, unsigned int n,
const unsigned long *args)
{
+ if (n == 0)
+ return;
+
if (i + n > SYSCALL_MAX_ARGS) {
pr_warning("%s called with max args %d, handling only %d\n",
__func__, i + n, SYSCALL_MAX_ARGS);
--
1.7.9.5
The sleep_length is computed in the tick_nohz_stop_sched_tick function but it
is used later in the code with in between the local irq enabled.
cpu_idle_loop
tick_nohz_idle_enter [ exits with local irq enabled ]
__tick_nohz_idle_enter
tick_nohz_stop_sched_tick
...
arch_cpu_idle
menu_select [ uses here 'sleep_length' ]
...
Between the computation of the sleep length and its usage, some interrupts
can occur, making the sleep length shorter than actually it is.
This patch fixes that by moving the sleep_length computation in the
tick_nohz_get_sleep_length function and store the next_event for the device
instead of the sleep_length.
Signed-off-by: Daniel Lezcano <daniel.lezcano(a)linaro.org>
---
include/linux/tick.h | 2 +-
kernel/time/tick-sched.c | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/include/linux/tick.h b/include/linux/tick.h
index 5128d33..4932004 100644
--- a/include/linux/tick.h
+++ b/include/linux/tick.h
@@ -67,7 +67,7 @@ struct tick_sched {
ktime_t idle_exittime;
ktime_t idle_sleeptime;
ktime_t iowait_sleeptime;
- ktime_t sleep_length;
+ ktime_t next_event;
unsigned long last_jiffies;
unsigned long next_jiffies;
ktime_t idle_expires;
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 3612fc7..2007a7f 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -673,7 +673,7 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts,
out:
ts->next_jiffies = next_jiffies;
ts->last_jiffies = last_jiffies;
- ts->sleep_length = ktime_sub(dev->next_event, now);
+ ts->next_event = dev->next_event;
return ret;
}
@@ -837,8 +837,9 @@ void tick_nohz_irq_exit(void)
ktime_t tick_nohz_get_sleep_length(void)
{
struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
+ ktime_t now = ktime_get();
- return ts->sleep_length;
+ return ktime_sub(ts->next_event, now);
}
static void tick_nohz_restart(struct tick_sched *ts, ktime_t now)
--
1.7.9.5
On Mon, 30 Sep 2013 12:00:36 -0700
Zi Shen Lim <zishen.lim(a)linaro.org> wrote:
> On Mon, Sep 30, 2013 at 12:03 PM, Anders Roxell
> <anders.roxell(a)linaro.org> wrote:
> > Hi,
> >
> > On 2013-09-30 11:48, Zi Shen Lim wrote:
> >> Signed-off-by: Zi Shen Lim <zishen.lim(a)linaro.org>
> >> ---
> >> linaro/configs/linaro-base.conf | 4 ++++
> >> 1 file changed, 4 insertions(+)
> >>
> >> diff --git a/linaro/configs/linaro-base.conf b/linaro/configs/linaro-base.conf
> >> index 947ca1f..0093640 100644
> >> --- a/linaro/configs/linaro-base.conf
> >> +++ b/linaro/configs/linaro-base.conf
> >> @@ -92,3 +92,7 @@ CONFIG_HW_PERF_EVENTS=y
> >> CONFIG_FUNCTION_TRACER=y
> >> CONFIG_ENABLE_DEFAULT_TRACERS=y
> >> CONFIG_PROC_DEVICETREE=y
> >> +CONFIG_HUGETLB_PAGE=y
> >> +CONFIG_HUGETLBFS=y
> >> +CONFIG_TRANSPARENT_HUGEPAGE=y
> >> +CONFIG_TRANSPARENT_HUGEPAGE_MADVISE=y
> > This CONFIG_* fragments are already in linaro/configs/linaro-base64.conf
> > right?
> >
>
> Isn't linaro-base64.conf meant for ARMv8?
>
> We need hugepage support on existing 32-bit / ARMv7 platforms too, don't we?
[adding linaro-kernel, Andrey]
Yes, it seems the base64 component is a misnomer, at least for now.
Meanwhile, if this patch is targeted to the main linaro kernel, please
send via the linaro-kernel list, cc'ing linaro-networking. If not,
then perhaps a separate .conf file is in order? Anyway, I think we'd
all prefer a resolution within the main linaro kernel for hugepage
support.
> > and we are building with it in our ci/job/linux-lng* scripts...
perhaps those should be patched as well.
Kim