From patchwork Tue Jun 17 22:10:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hogan X-Patchwork-Id: 4371491 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 264799F758 for ; Tue, 17 Jun 2014 22:14:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 47C49201B9 for ; Tue, 17 Jun 2014 22:14:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5CD60202F2 for ; Tue, 17 Jun 2014 22:14:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967166AbaFQWOj (ORCPT ); Tue, 17 Jun 2014 18:14:39 -0400 Received: from mailapp01.imgtec.com ([195.59.15.196]:30860 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967040AbaFQWOM (ORCPT ); Tue, 17 Jun 2014 18:14:12 -0400 Received: from KLMAIL01.kl.imgtec.org (unknown [192.168.5.35]) by Websense Email Security Gateway with ESMTPS id BA310D0919A12; Tue, 17 Jun 2014 23:14:03 +0100 (IST) Received: from LEMAIL01.le.imgtec.org (192.168.152.62) by KLMAIL01.kl.imgtec.org (192.168.5.35) with Microsoft SMTP Server (TLS) id 14.3.181.6; Tue, 17 Jun 2014 23:10:49 +0100 Received: from jhogan-linux.le.imgtec.org (192.168.154.101) by LEMAIL01.le.imgtec.org (192.168.152.62) with Microsoft SMTP Server (TLS) id 14.3.174.1; Tue, 17 Jun 2014 23:10:48 +0100 From: James Hogan To: CC: , Aurelien Jarno , Gleb Natapov , Paolo Bonzini , Sanjay Lal , James Hogan , Peter Maydell Subject: [PATCH v5 06/12] kvm: Allow arch to set sigmask length Date: Tue, 17 Jun 2014 23:10:31 +0100 Message-ID: <1403043037-1271-7-git-send-email-james.hogan@imgtec.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1403043037-1271-1-git-send-email-james.hogan@imgtec.com> References: <1403043037-1271-1-git-send-email-james.hogan@imgtec.com> MIME-Version: 1.0 X-Originating-IP: [192.168.154.101] Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP MIPS/Linux is unusual in having 128 signals rather than just 64 like most other architectures. This means its sigmask is 16 bytes instead of 8, so allow arches to override the sigmask->len value passed to the KVM_SET_SIGNAL_MASK ioctl in kvm_set_signal_mask() by calling kvm_set_sigmask_len() from kvm_arch_init(). Otherwise default to 8 bytes. Signed-off-by: James Hogan Cc: Aurelien Jarno Cc: Sanjay Lal Cc: Gleb Natapov Cc: Paolo Bonzini Cc: Peter Maydell --- Changes in v3: - Rewrote to allow sigmask length to be set by kvm_arch_init(), so that MIPS can set it to 16 as it has 128 signals. This is better than cluttering kvm-all.c with TARGET_* ifdefs (Peter Maydell). Changes in v2: - Expand commit message - Reword comment --- include/sysemu/kvm.h | 2 ++ kvm-all.c | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index e79e92c50e3f..de4bdaa40e56 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -325,6 +325,8 @@ int kvm_check_extension(KVMState *s, unsigned int extension); uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function, uint32_t index, int reg); +void kvm_set_sigmask_len(KVMState *s, unsigned int sigmask_len); + #if !defined(CONFIG_USER_ONLY) int kvm_physical_memory_addr_from_host(KVMState *s, void *ram_addr, hwaddr *phys_addr); diff --git a/kvm-all.c b/kvm-all.c index 4e19eff0efee..0d485b644539 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -99,6 +99,7 @@ struct KVMState * they're not. Linux, glibc and *BSD all treat ioctl numbers as * unsigned, and treating them as signed here can break things */ unsigned irq_set_ioctl; + unsigned int sigmask_len; #ifdef KVM_CAP_IRQ_ROUTING struct kvm_irq_routing *irq_routes; int nr_allocated_irq_routes; @@ -1397,6 +1398,8 @@ int kvm_init(MachineClass *mc) assert(TARGET_PAGE_SIZE <= getpagesize()); page_size_init(); + s->sigmask_len = 8; + #ifdef KVM_CAP_SET_GUEST_DEBUG QTAILQ_INIT(&s->kvm_sw_breakpoints); #endif @@ -1575,6 +1578,11 @@ err: return ret; } +void kvm_set_sigmask_len(KVMState *s, unsigned int sigmask_len) +{ + s->sigmask_len = sigmask_len; +} + static void kvm_handle_io(uint16_t port, void *data, int direction, int size, uint32_t count) { @@ -2095,6 +2103,7 @@ void kvm_remove_all_breakpoints(CPUState *cpu) int kvm_set_signal_mask(CPUState *cpu, const sigset_t *sigset) { + KVMState *s = kvm_state; struct kvm_signal_mask *sigmask; int r; @@ -2104,7 +2113,7 @@ int kvm_set_signal_mask(CPUState *cpu, const sigset_t *sigset) sigmask = g_malloc(sizeof(*sigmask) + sizeof(*sigset)); - sigmask->len = 8; + sigmask->len = s->sigmask_len; memcpy(sigmask->sigset, sigset, sizeof(*sigset)); r = kvm_vcpu_ioctl(cpu, KVM_SET_SIGNAL_MASK, sigmask); g_free(sigmask);