From patchwork Mon Oct 19 10:59:25 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 54738 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9JB4peL026141 for ; Mon, 19 Oct 2009 11:04:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756004AbZJSLEo (ORCPT ); Mon, 19 Oct 2009 07:04:44 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756032AbZJSLEn (ORCPT ); Mon, 19 Oct 2009 07:04:43 -0400 Received: from david.siemens.de ([192.35.17.14]:17255 "EHLO david.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755948AbZJSLEh (ORCPT ); Mon, 19 Oct 2009 07:04:37 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by david.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id n9JB4Sif025640; Mon, 19 Oct 2009 13:04:28 +0200 Received: from [139.25.109.167] (mchn012c.mchp.siemens.de [139.25.109.167] (may be forged)) by mail1.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id n9JB4SEj020787; Mon, 19 Oct 2009 13:04:28 +0200 From: Jan Kiszka Subject: [PATCH 11/12] x86: Install compat wrapper for thread_struct.debugreg To: Avi Kivity , Marcelo Tosatti Cc: kvm@vger.kernel.org Date: Mon, 19 Oct 2009 12:59:25 +0200 Message-ID: <20091019105924.3988.39235.stgit@mchn012c.ww002.siemens.net> In-Reply-To: <20091019105923.3988.42243.stgit@mchn012c.ww002.siemens.net> References: <20091019105923.3988.42243.stgit@mchn012c.ww002.siemens.net> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/sync b/sync index 8868e6d..da5c218 100755 --- a/sync +++ b/sync @@ -133,6 +133,8 @@ def __hack(data): line = '\t{ struct page *mapped_page;\n' + sub(r'\);', ', &mapped_page);', line) if match('nested_svm_unmap(.*);'): line = sub(r'\);', ', mapped_page); }', line) + if match(r'->thread.debugreg[0-7]'): + line = sub(r'->thread.debugreg([0-7])', r'->thread.kvm_compat_debugreg(\1)', line) w(line) if match(r'\tkvm_init_debug'): w('\thrtimer_kallsyms_resolve();') diff --git a/x86/external-module-compat.h b/x86/external-module-compat.h index 7056aa1..b32e68e 100644 --- a/x86/external-module-compat.h +++ b/x86/external-module-compat.h @@ -571,6 +571,12 @@ static inline unsigned long kvm_get_desc_limit(const struct kvm_desc_struct *des #endif +#if !defined(CONFIG_X86_64) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) +#define kvm_compat_debugreg(x) debugreg[x] +#else +#define kvm_compat_debugreg(x) debugreg##x +#endif + #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) struct mtrr_var_range { diff --git a/x86/preempt.c b/x86/preempt.c index 3112879..440060b 100644 --- a/x86/preempt.c +++ b/x86/preempt.c @@ -13,17 +13,11 @@ static LIST_HEAD(pn_list); current->pid, raw_smp_processor_id()); \ } while (0) -#if !defined(CONFIG_X86_64) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)) -#define debugreg(x) debugreg[x] -#else -#define debugreg(x) debugreg##x -#endif - static void preempt_enable_sched_out_notifiers(void) { asm volatile ("mov %0, %%db0" : : "r"(schedule)); asm volatile ("mov %0, %%db7" : : "r"(0x701ul)); - current->thread.debugreg(7) = 0ul; + current->thread.kvm_compat_debugreg(7) = 0ul; #ifdef TIF_DEBUG clear_tsk_thread_flag(current, TIF_DEBUG); #endif @@ -33,8 +27,8 @@ static void preempt_enable_sched_in_notifiers(void * addr) { asm volatile ("mov %0, %%db0" : : "r"(addr)); asm volatile ("mov %0, %%db7" : : "r"(0x701ul)); - current->thread.debugreg(0) = (unsigned long) addr; - current->thread.debugreg(7) = 0x701ul; + current->thread.kvm_compat_debugreg(0) = (unsigned long) addr; + current->thread.kvm_compat_debugreg(7) = 0x701ul; #ifdef TIF_DEBUG set_tsk_thread_flag(current, TIF_DEBUG); #endif @@ -48,7 +42,7 @@ static void __preempt_disable_notifiers(void) static void preempt_disable_notifiers(void) { __preempt_disable_notifiers(); - current->thread.debugreg(7) = 0ul; + current->thread.kvm_compat_debugreg(7) = 0ul; #ifdef TIF_DEBUG clear_tsk_thread_flag(current, TIF_DEBUG); #endif @@ -235,7 +229,7 @@ static void do_disable(void *blah) #ifdef TIF_DEBUG if (!test_tsk_thread_flag(current, TIF_DEBUG)) #else - if (!current->thread.debugreg(7)) + if (!current->thread.kvm_compat_debugreg(7)) #endif __preempt_disable_notifiers(); }