Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755876AbcJFOM1 (ORCPT ); Thu, 6 Oct 2016 10:12:27 -0400 Received: from smtp02.citrix.com ([66.165.176.63]:56273 "EHLO SMTP02.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754215AbcJFOMJ (ORCPT ); Thu, 6 Oct 2016 10:12:09 -0400 X-IronPort-AV: E=Sophos;i="5.31,454,1473120000"; d="scan'208";a="391079657" Subject: Re: [Xen-devel] [PATCH] xen/x86: Update topology map for PV VCPUs To: Boris Ostrovsky , , References: <1475687373-14589-1-git-send-email-boris.ostrovsky@oracle.com> CC: , , , From: David Vrabel Message-ID: Date: Thu, 6 Oct 2016 15:12:04 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.3.0 MIME-Version: 1.0 In-Reply-To: <1475687373-14589-1-git-send-email-boris.ostrovsky@oracle.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-DLP: MIA2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 977 Lines: 24 On 05/10/16 18:09, Boris Ostrovsky wrote: > Early during boot topology_update_package_map() computes > logical_pkg_ids for all present processors. > > Later, when processors are brought up, identify_cpu() updates > these values based on phys_pkg_id which is a function of > initial_apicid. On PV guests the latter may point to a > non-existing node, causing logical_pkg_ids to be set to -1. > > Intel's RAPL uses logical_pkg_id (as topology_logical_package_id()) > to index its arrays and therefore in this case will point to index > 65535 (since logical_pkg_id is a u16). This could lead to either a > crash or may actually access random memory location. > > As a workaround, we recompute topology during CPU bringup to reset > logical_pkg_id to a valid value. > > (The reason for initial_apicid being bogus is because it is > initial_apicid of the processor from which the guest is launched. > This value is CPUID(1).EBX[31:24]) Applied to for-linus-4.9, thanks. David