Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3460214pxb; Mon, 25 Jan 2021 17:30:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJzl+XwBV27n7t5DdEO+zlvll2/7Pp4ogIFuB+MlzksgcF0BNikgf8Mv8u08ZidJpy6yD/ X-Received: by 2002:a05:6402:1f4:: with SMTP id i20mr2614855edy.180.1611624651716; Mon, 25 Jan 2021 17:30:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611624651; cv=none; d=google.com; s=arc-20160816; b=QXJkT3TBevwd+inhWY/8+hfT/s4gR0lSO0rUX4GCKtWXebK1G6crr0ZKoUOPfP6L7L qhVZ926G3mr0hOE8bnaxqYc4dzovnZPO8vNtbyatA9oRMeXss903u/Z62Cnm5QZQ+vIa py+hkjIS+C1U2I9zYDHFe2MpWSjWbT7UfgXh796ho+xx6sSalWivA41vlNCUmmI18IzU /vk6KjtMWi6V3Jhw3LZmjR3Zo45cXnmfWHFpb7p9dcHNKUbV06hlbN/3e5E7qoCN4svi qWK+0Fd6WQVC3iiDJvOJMQOl7C/6Wnhvd4CyQ//cl6+nypQnb3WbYMRFp3IukKsEwzwl JEvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=M806RwSdSdwKbvwGDaC+qzQtQImQxTaCCUbp86ogdk8=; b=Ofpjo7DH/kplkD8ID68WlmJwDvsOtzrskwadQNYfcjUJOsm31G0sAUpRA/iYtuhM32 OWu7TA+K77lJB7Sv/kNMpAExAD2Jgg3rTyKnO0yf0iF0rUoWuUZZYLGL+RLG5AZ8xj3v GJmNrNfmiQqo7k+c+yCFy6LREdR56IrPEBd2pRoIxhhqPkcd4iWOBgxhgz84PzbwElAX q/BI1QlOzg8J03rGULxViPJAtyKmo9QhFZooA1Q1kBDBY2+G75SWkVr1GeLX5xIylN/e kOjh8wEwked6fjrn+WQCj6n006heJngrlHaZzg2dTaNQzMFwZ1lf3o/Bx3KVe3ED/G3s n1dw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l14si8094957edw.437.2021.01.25.17.30.27; Mon, 25 Jan 2021 17:30:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727813AbhAYMSP (ORCPT + 99 others); Mon, 25 Jan 2021 07:18:15 -0500 Received: from mga01.intel.com ([192.55.52.88]:46241 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727840AbhAYMLv (ORCPT ); Mon, 25 Jan 2021 07:11:51 -0500 IronPort-SDR: sBqxBS27qKLr5Zl5bFMoXs6jGc1V8tOpoEKo4R0oLeHZKysFwDPMD7UMJZLcxN2Gq7nuXYE03Z KvNMRgB5CUOQ== X-IronPort-AV: E=McAfee;i="6000,8403,9874"; a="198490980" X-IronPort-AV: E=Sophos;i="5.79,373,1602572400"; d="scan'208";a="198490980" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2021 04:07:15 -0800 IronPort-SDR: srAIfgl2Dd3Ozn5+UAs0t1kA2kq44zNVb3giqtvLPBtuWJo5JEGWkpORWEHVYU1o5wtWZC1bj3 Ae6NZFtFqLWA== X-IronPort-AV: E=Sophos;i="5.79,373,1602572400"; d="scan'208";a="387338811" Received: from likexu-mobl1.ccr.corp.intel.com (HELO [10.249.168.247]) ([10.249.168.247]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2021 04:07:10 -0800 Subject: Re: [PATCH v3 00/17] KVM: x86/pmu: Add support to enable Guest PEBS via DS To: Peter Zijlstra Cc: Sean Christopherson , Andi Kleen , Kan Liang , Paolo Bonzini , eranian@google.com, kvm@vger.kernel.org, Ingo Molnar , Thomas Gleixner , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , wei.w.wang@intel.com, luwei.kang@intel.com, linux-kernel@vger.kernel.org, Like Xu References: <20210104131542.495413-1-like.xu@linux.intel.com> <20210115182700.byczztx3vjhsq3p3@two.firstfloor.org> From: "Xu, Like" Message-ID: <076a5c7b-de2e-daf9-e6c0-5a42fb38aaa3@intel.com> Date: Mon, 25 Jan 2021 20:07:06 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/1/25 19:13, Peter Zijlstra wrote: > On Mon, Jan 25, 2021 at 04:08:22PM +0800, Like Xu wrote: >> Hi Peter, >> >> On 2021/1/22 17:56, Peter Zijlstra wrote: >>> On Fri, Jan 15, 2021 at 10:51:38AM -0800, Sean Christopherson wrote: >>>> On Fri, Jan 15, 2021, Andi Kleen wrote: >>>>>> I'm asking about ucode/hardare. Is the "guest pebs buffer write -> PEBS PMI" >>>>>> guaranteed to be atomic? >>>>> Of course not. >>>> So there's still a window where the guest could observe the bad counter index, >>>> correct? >>> Guest could do a hypercall to fix up the DS area before it tries to read >>> it I suppose. Or the HV could expose the index mapping and have the >>> guest fix up it. >> A weird (malicious) guest would read unmodified PEBS records in the >> guest PEBS buffer from other vCPUs without the need for hypercall or >> index mapping from HV. >> >> Do you see any security issues on this host index leak window? >> >>> Adding a little virt crud on top shouldn't be too hard. >>> >> The patches 13-17 in this version has modified the guest PEBS buffer >> to correct the index mapping information in the guest PEBS records. > Right, but given there is no atomicity between writing the DS area and > triggering the PMI (as already established earlier in this thread), a > malicious guest can already access this information, no? > So under the premise that counter cross-mapping is allowed, how can hypercall help fix it ? Personally,  I think it is acceptable at the moment, and no security issues based on this have been defined and found.