From patchwork Sun Nov 27 02:45:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 127831 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 31B33B712A for ; Sun, 27 Nov 2011 13:46:12 +1100 (EST) Received: from localhost ([::1]:36022 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RUUke-0008QO-Ox for incoming@patchwork.ozlabs.org; Sat, 26 Nov 2011 21:45:56 -0500 Received: from eggs.gnu.org ([140.186.70.92]:51157) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RUUkZ-0008Q5-8v for qemu-devel@nongnu.org; Sat, 26 Nov 2011 21:45:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RUUkY-0008Nl-6e for qemu-devel@nongnu.org; Sat, 26 Nov 2011 21:45:51 -0500 Received: from mail-iy0-f173.google.com ([209.85.210.173]:55216) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RUUkX-0008Nh-VW for qemu-devel@nongnu.org; Sat, 26 Nov 2011 21:45:50 -0500 Received: by iakk32 with SMTP id k32so7711723iak.4 for ; Sat, 26 Nov 2011 18:45:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=VsODgc7TxyKbKIfEvLohGvq4Wp4sKEkJqpsnHOCeDiA=; b=mvQAHYcwRkWlIAVfLSAjjPpuzwS8rIvE0+Vb0Zq0cjQ5Vn/fMHM970pHdT5CBMb2+f jXGNQA66JuNHWgFKirbnWjNaHncmEHRXBZ4XJXX8QqPSND2SqkYw8/+877sMNaRO6z2V 7GK5ES1ilkm8GTgAwYE8obkm4kFq3qpwJSmks= Received: by 10.42.153.6 with SMTP id k6mr18636444icw.30.1322361949518; Sat, 26 Nov 2011 18:45:49 -0800 (PST) Received: from localhost ([111.192.255.64]) by mx.google.com with ESMTPS id el2sm24768027ibb.10.2011.11.26.18.45.43 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 26 Nov 2011 18:45:48 -0800 (PST) From: Liu Ping Fan To: kvm@vger.kernel.org, qemu-devel@nongnu.org Date: Sun, 27 Nov 2011 10:45:33 +0800 Message-Id: <1322361937-22438-1-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 1.7.4.4 In-Reply-To: <1322188529-11609-1-git-send-email-kernelfans@gmail.com> References: <1322188529-11609-1-git-send-email-kernelfans@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.210.173 Cc: aliguori@us.ibm.com, ryanh@us.ibm.com, jan.kiszka@web.de, linux-kernel@vger.kernel.org, avi@redhat.com Subject: [Qemu-devel] [PATCH 1/5] QEMU Add cpu_phyid_to_cpu() to map cpu phyid to CPUState X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Liu Ping Fan The guest has different cpu logic id from qemu, but they have the same phyid. When cpu phyid is told by guest, we need to obtain the corresponding CPUState. Signed-off-by: Liu Ping Fan --- target-i386/cpu.h | 2 ++ target-i386/helper.c | 12 ++++++++++++ 2 files changed, 14 insertions(+), 0 deletions(-) diff --git a/target-i386/cpu.h b/target-i386/cpu.h index abdeb40..251e63b 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -767,6 +767,7 @@ typedef struct CPUX86State { } CPUX86State; CPUX86State *cpu_x86_init(const char *cpu_model); +CPUX86State *x86_phyid_to_cpu(int phy_id); int cpu_x86_exec(CPUX86State *s); void cpu_x86_close(CPUX86State *s); void x86_cpu_list (FILE *f, fprintf_function cpu_fprintf, const char *optarg); @@ -1063,4 +1064,5 @@ void svm_check_intercept(CPUState *env1, uint32_t type); uint32_t cpu_cc_compute_all(CPUState *env1, int op); +#define cpu_phyid_to_cpu x86_phyid_to_cpu #endif /* CPU_I386_H */ diff --git a/target-i386/helper.c b/target-i386/helper.c index 5df40d4..e35a75e 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -1263,6 +1263,18 @@ CPUX86State *cpu_x86_init(const char *cpu_model) return env; } +CPUX86State *x86_phyid_to_cpu(int phy_id) +{ + CPUX86State *env = first_cpu; + while (env) { + if (env->cpuid_apic_id == phy_id) { + break; + } + env = env->next_cpu; + } + return env; +} + #if !defined(CONFIG_USER_ONLY) void do_cpu_init(CPUState *env) {