Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp654224pxb; Tue, 2 Feb 2021 14:29:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOejVcqaK4OqLsgSiIg2OzFIbQ4MUzRzluFPhAKVRLrgAjv41A4IbuXhwb9YmyFzdCvN6A X-Received: by 2002:a50:b223:: with SMTP id o32mr251511edd.79.1612304988539; Tue, 02 Feb 2021 14:29:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612304988; cv=none; d=google.com; s=arc-20160816; b=weTuC5LpTf6QDoeclOFtxE1hqNWazFTP68cDAmQ8g8zBlA86P/PHZ7iLtUJVBogvS6 hKv5cLqr+P+VuhNd5sGeUw1TwtPEPikxkqJCA+lr33kpP7/lCAMORfYF8FXlHKglWbkc w8ttnuPnzC+WE71ZuX53UQ/7gDSmGd6gH3EwaVXOmjcvdYhiDbe1XRnOkzbYTChpEK0L 4EnbkiSajmJeZn2mZiCg4eSBqmCi5rrK43LhvfKGGpNj4kXbfFM2TcWJ5bfeb0tjCPoe fJWCe6/uUAjBYi9ANo4cUW4sauR2ttR/C1s3nwkoDtUcUGf9eIRC8YLgqjfCmMMH/KAx 6cQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=63iUIFUeXpHPrYf2eKlD+tbc5HBRhOL3GBF5o8JxTlk=; b=EuxsvIX3HLnvnBYRhDbkXvQWBcX9K5wAWz6qPf89IrFalpyqPSrPNwBsLkzlaiPHtB KahnajhwXraveYIt08SH1KQ8YPBgTydvAb9ODy5lqJClrgg3plQghe4nNDv0jDj1tGgA 1piogTjbDgUo855igakV6tAoAjD7lDEow2k75wXL0cxP0l2SngED5bmmNrNaOmo5tApc yU914pELMLON9j4sUsRX3gJ9+5csYnlr2AJQPxtXt2BgsOYYaD6bJqgP6RpzHqH+VDST DSKmENZJZgs2FiL3IUtFLYDUngKru8uwZr+EaFNlwsAucS60OrmXoqhwQmW1WSZrpTNc 37gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AecdHk59; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o22si126302ejb.592.2021.02.02.14.29.21; Tue, 02 Feb 2021 14:29:48 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AecdHk59; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234627AbhBBO4N (ORCPT + 99 others); Tue, 2 Feb 2021 09:56:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:59461 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233019AbhBBOzN (ORCPT ); Tue, 2 Feb 2021 09:55:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612277624; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=63iUIFUeXpHPrYf2eKlD+tbc5HBRhOL3GBF5o8JxTlk=; b=AecdHk59BaWFIhfosA8h4M6FOExtBAzF0tI+McGk9/kyFcM/ahFjtsH4SLn11bYxzvmy5M jLFDcz6227VDulba4oqFQP5UAYNLdTTIXaIT79rNZKz3MYWeERo3b7TWwi8uS1Je4Qwber 6VSwURCx3p3CS8xMiQ8FbgVUDXk0jps= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-450-STswga_eNPm23MSLpo_Wrw-1; Tue, 02 Feb 2021 09:53:42 -0500 X-MC-Unique: STswga_eNPm23MSLpo_Wrw-1 Received: by mail-ed1-f70.google.com with SMTP id y6so9697769edc.17 for ; Tue, 02 Feb 2021 06:53:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=63iUIFUeXpHPrYf2eKlD+tbc5HBRhOL3GBF5o8JxTlk=; b=A5dJ9b+t9zrC5E0DKgd+KJ4P1KtxIj+1ya7unWxBfjYvFAsbx9ArxIgFkGDPe3EZVb /CT09AAmZJNTiIbJFrEXZw/ZS8XDq3XAzBW9fcjvAaEHeaRo37NG4G1f4wnn73aiBzRw 8fAj8SPF5n0AX0zckZ2cy1OfFz7U1JD8C5wMcp5JY9GJi8RFrelIBYyrFYgnr50rQLKU JVMg/66ohjLfxk5wGRyEHrjZiN6goee4M0tUJ4iF5pNBUDdFZw1i4zWYqGIwoLyrNV62 O4Wkp/sKiB+dOuxS+pEJ+QO/+9LwJDkBIOsTgGnhzlAD+FKQpN/sf1lm4gIaN7vJvwUR bMtA== X-Gm-Message-State: AOAM531s9p6NLwLT2NdIy9acDRKQiqoxUYn7JuNdNqXcVUDKY8X8NIlG Mih8PDRHWuH6vLuCV8EskehtWTtr0wxeqWhjZETznqeeo26HmDAMryaD/mxlQtA1qTTqxeUtni8 FDk5gZSUjRp7BtrUDHAuxuGLIWKbgxu3pZ4OKQ3GTWEAHc5I+cawrIPgHCDDkmuz+fH47VyMC1m jV X-Received: by 2002:aa7:da98:: with SMTP id q24mr24166767eds.370.1612277621023; Tue, 02 Feb 2021 06:53:41 -0800 (PST) X-Received: by 2002:aa7:da98:: with SMTP id q24mr24166742eds.370.1612277620810; Tue, 02 Feb 2021 06:53:40 -0800 (PST) Received: from ?IPv6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id x17sm9996283edd.76.2021.02.02.06.53.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 Feb 2021 06:53:39 -0800 (PST) Subject: Re: [PATCH v14 11/11] selftests: kvm/x86: add test for pmu msr MSR_IA32_PERF_CAPABILITIES To: Like Xu , Sean Christopherson Cc: Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , ak@linux.intel.com, wei.w.wang@intel.com, kan.liang@intel.com, alex.shi@linux.alibaba.com, kvm@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org References: <20210201051039.255478-1-like.xu@linux.intel.com> <20210201060152.370069-1-like.xu@linux.intel.com> <20210201060152.370069-5-like.xu@linux.intel.com> From: Paolo Bonzini Message-ID: Date: Tue, 2 Feb 2021 15:53:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20210201060152.370069-5-like.xu@linux.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/02/21 07:01, Like Xu wrote: > > +uint64_t rdmsr_on_cpu(uint32_t reg) > +{ > + uint64_t data; > + int fd; > + char msr_file[64]; > + > + sprintf(msr_file, "/dev/cpu/%d/msr", 0); > + fd = open(msr_file, O_RDONLY); > + if (fd < 0) > + exit(KSFT_SKIP); > + > + if (pread(fd, &data, sizeof(data), reg) != sizeof(data)) > + exit(KSFT_SKIP); > + > + close(fd); > + return data; > +} In order to allow running as non-root, it's better to use the KVM_GET_MSRS ioctl on the /dev/kvm file descriptor. The tests pass, but please take a look at the kvm/queue branch to see if everything is ok. Paolo