From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9629C2B9F4 for ; Thu, 17 Jun 2021 11:40:08 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 5D51961403 for ; Thu, 17 Jun 2021 11:40:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D51961403 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id DD02E4A98B; Thu, 17 Jun 2021 07:40:07 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@redhat.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id I+0BiALIBmvs; Thu, 17 Jun 2021 07:40:06 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id CBB0F4A3A3; Thu, 17 Jun 2021 07:40:06 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id D9EBB40895 for ; Thu, 17 Jun 2021 07:40:05 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JPkkNgB5toHO for ; Thu, 17 Jun 2021 07:40:04 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mm01.cs.columbia.edu (Postfix) with ESMTP id E065949FB7 for ; Thu, 17 Jun 2021 07:40:04 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623930004; 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=VmCLvCRTlrH58yubKa8HF1xENLoVvDewdsvG/LgtDCE=; b=Hbnw17cNBFLAb0Ev5LLadVB/xu5K/s/dPXU8cxiotUGZ92vFC2khCwksCgNdJJJ1uKI0Ae gbTancehgIMUepj8DHd4seA1lWhTZfsqWhl5eI9JLGYXHDNAOovml/xbCnrJlAXRHzStDM L4axasrUxI0GRvFiGhzR3zguQdfCE9Y= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-171-DpWSOZmiMfCXSPVZmU4B2w-1; Thu, 17 Jun 2021 07:40:03 -0400 X-MC-Unique: DpWSOZmiMfCXSPVZmU4B2w-1 Received: by mail-ej1-f70.google.com with SMTP id jw19-20020a17090776b3b0290481592f1fc4so389692ejc.2 for ; Thu, 17 Jun 2021 04:40:03 -0700 (PDT) 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=VmCLvCRTlrH58yubKa8HF1xENLoVvDewdsvG/LgtDCE=; b=Faw0k7Klt90eBoUmpXJDqA7BhNqKUmFskhhxVuWi4UOB8tYp/VShfQok9SuYu0AeKg qYs7j6Sq2RaDhUaLagy3u8BjBaIfFo+NKMnHF513pMra1qjdjbhG/mrB57qRuLXoEW5j oIh0x38V+IEK9KSxsQkLCZfIV4tT7NxzZSBIRtn7EN+zQyk/GZOHiPfojpminamIbYv9 bKCct+/T1IpSePmOirjw7rQ/Kpyrc1hxOy5abTfUNPwsceCE/K84sqGCzguz1kb0ks/8 8PP0A9OqT/gt9+oo50Le5KNepqaO8te1jZOxxuKBFJvgdUIKi0KZUQXKYaI0GnlFn0Dw NhNg== X-Gm-Message-State: AOAM533bByn/S1IMfmsWxau7w+bkwtvmbUP8L5Jx9Co8ShocK7/gkFoo DORb7nuxN5aM70+byD15zS2dFd35Kr4c/quC/Wh/asmKikyknGbN0k7fhLu0BVaBua5BlrfA/1M nykXfZwiTGL0GwY7Ujtz9OAiC X-Received: by 2002:a17:906:b317:: with SMTP id n23mr4753243ejz.324.1623929020562; Thu, 17 Jun 2021 04:23:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhbQ8ssqFmZsWb8sMpnt1Xu4dlg8VyEm5RPjNu6NQPEN0NLgvmdDkk7J48/7gKKGpvO8cI2w== X-Received: by 2002:a17:906:b317:: with SMTP id n23mr4753201ejz.324.1623929020383; Thu, 17 Jun 2021 04:23:40 -0700 (PDT) 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 by23sm3167995ejc.85.2021.06.17.04.23.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Jun 2021 04:23:39 -0700 (PDT) Subject: Re: [PATCH v10 2/5] KVM: stats: Add fd-based API to read binary stats data To: Greg KH , Jing Zhang References: <20210617044146.2667540-1-jingzhangos@google.com> <20210617044146.2667540-3-jingzhangos@google.com> From: Paolo Bonzini Message-ID: Date: Thu, 17 Jun 2021 13:23:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Cc: KVM , David Hildenbrand , Paul Mackerras , Linuxkselftest , Claudio Imbrenda , Will Deacon , KVMARM , Emanuele Giuseppe Esposito , LinuxS390 , Janosch Frank , Marc Zyngier , Huacai Chen , Christian Borntraeger , Aleksandar Markovic , David Rientjes , KVMPPC , Krish Sadhukhan , David Matlack , Jim Mattson , Thomas Bogendoerfer , Sean Christopherson , Cornelia Huck , Peter Shier , LinuxMIPS , Vitaly Kuznetsov X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On 17/06/21 09:03, Greg KH wrote: >> 3. Fd-based solution provides the possibility that a telemetry can >> read KVM stats in a less privileged situation. > "possiblity"? Does this work or not? Have you tested it? > I think this is essentially s/that/for/. But more precisely: 3. Compared for example to a ioctl, a separate file descriptor makes it possible for an external program to read statistics, while maintaining privilege separation between VMM and telemetry code. >> >> + snprintf(&kvm_vm_stats_header.id[0], sizeof(kvm_vm_stats_header.id), >> + "kvm-%d", task_pid_nr(current)); > > Why do you write to this static variable for EVERY read? Shouldn't you > just do it once at open? How can it change? > > Wait, it's a single shared variable, what happens when multiple tasks > open this thing and read from it? You race between writing to this > variable here and then: > >> + return kvm_stats_read(&kvm_vm_stats_header, &kvm_vm_stats_desc[0], >> + &kvm->stat, sizeof(kvm->stat), user_buffer, size, offset); > > Accessing it here. > > So how is this really working? It's not - Jing, kvm_vm_stats_header is small enough that you can store a copy in struct kvm. Paolo _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DDC7C2B9F4 for ; Thu, 17 Jun 2021 11:40:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0D7B261403 for ; Thu, 17 Jun 2021 11:40:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231650AbhFQLmx (ORCPT ); Thu, 17 Jun 2021 07:42:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32012 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229584AbhFQLmw (ORCPT ); Thu, 17 Jun 2021 07:42:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623930044; 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=VmCLvCRTlrH58yubKa8HF1xENLoVvDewdsvG/LgtDCE=; b=JmtnJ+vI46IrWC3Ad6CcbLJgND99T4RwISqRYbbucL945rC5pg9YHK84MWPgctvfMz9knk Zy3hBm1swfIz0gtagSi665iT5ydm1OlKO0pu0fP1YJ7vw95fA9Z9cU+UgvUoJQZpu55TVO hdiLnRxs8rYUZ+yWEur5MqWEyamytAM= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-584-QGGpWuuKNlmH6MnzokfRLQ-1; Thu, 17 Jun 2021 07:40:43 -0400 X-MC-Unique: QGGpWuuKNlmH6MnzokfRLQ-1 Received: by mail-ej1-f71.google.com with SMTP id nd10-20020a170907628ab02903a324b229bfso2068702ejc.7 for ; Thu, 17 Jun 2021 04:40:43 -0700 (PDT) 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=VmCLvCRTlrH58yubKa8HF1xENLoVvDewdsvG/LgtDCE=; b=C0TVLjSnTindnKgYP7ccdkC6dBseZW1l5+eSSZXcZN5ddyaPF7KOX9vutWyztF4q2l 6pgfXy89RwBvhsfFnWcaWDystdCbiWVhY6OuRB1EL84V8QqKFwT3EBOkXTmkVVenvdFH owi7FzD8i/IA3h72JW6UwfKy+hu3MCG29bZoqr34mZdmDFsp1pvndrLL41daaju650A/ hLnRZzVX6TGXsAh672/tz1eqTkYZil/e/p4ZBBj5pnwLx+KSfP8hBWsOr9u27Ta1DuRe g6oS39pxStDyi3dPpZmWjVESK8+par/uE0GIWCAQPiOIN5vYv7xqoBoE7PtvDV+97959 7M4Q== X-Gm-Message-State: AOAM531VFjQxPxOug2LbqFV4N/H3itBZrv5O4r2iyCfe/Le69ITHloGm aKjL/a/zMQkIp9pcIoe0D5uMSK0TVA+BgRpTxLfsYjuY/O6ESHU55+LC7ukS6BvK5QUL9ro2Cw9 SyrTN7pL8yKSFBf4bHZDiww== X-Received: by 2002:a17:906:b317:: with SMTP id n23mr4753222ejz.324.1623929020526; Thu, 17 Jun 2021 04:23:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhbQ8ssqFmZsWb8sMpnt1Xu4dlg8VyEm5RPjNu6NQPEN0NLgvmdDkk7J48/7gKKGpvO8cI2w== X-Received: by 2002:a17:906:b317:: with SMTP id n23mr4753201ejz.324.1623929020383; Thu, 17 Jun 2021 04:23:40 -0700 (PDT) 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 by23sm3167995ejc.85.2021.06.17.04.23.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Jun 2021 04:23:39 -0700 (PDT) Subject: Re: [PATCH v10 2/5] KVM: stats: Add fd-based API to read binary stats data To: Greg KH , Jing Zhang Cc: KVM , KVMARM , LinuxMIPS , KVMPPC , LinuxS390 , Linuxkselftest , Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Will Deacon , Huacai Chen , Aleksandar Markovic , Thomas Bogendoerfer , Paul Mackerras , Christian Borntraeger , Janosch Frank , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Sean Christopherson , Vitaly Kuznetsov , Jim Mattson , Peter Shier , Oliver Upton , David Rientjes , Emanuele Giuseppe Esposito , David Matlack , Ricardo Koller , Krish Sadhukhan , Fuad Tabba References: <20210617044146.2667540-1-jingzhangos@google.com> <20210617044146.2667540-3-jingzhangos@google.com> From: Paolo Bonzini Message-ID: Date: Thu, 17 Jun 2021 13:23:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: 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-mips@vger.kernel.org On 17/06/21 09:03, Greg KH wrote: >> 3. Fd-based solution provides the possibility that a telemetry can >> read KVM stats in a less privileged situation. > "possiblity"? Does this work or not? Have you tested it? > I think this is essentially s/that/for/. But more precisely: 3. Compared for example to a ioctl, a separate file descriptor makes it possible for an external program to read statistics, while maintaining privilege separation between VMM and telemetry code. >> >> + snprintf(&kvm_vm_stats_header.id[0], sizeof(kvm_vm_stats_header.id), >> + "kvm-%d", task_pid_nr(current)); > > Why do you write to this static variable for EVERY read? Shouldn't you > just do it once at open? How can it change? > > Wait, it's a single shared variable, what happens when multiple tasks > open this thing and read from it? You race between writing to this > variable here and then: > >> + return kvm_stats_read(&kvm_vm_stats_header, &kvm_vm_stats_desc[0], >> + &kvm->stat, sizeof(kvm->stat), user_buffer, size, offset); > > Accessing it here. > > So how is this really working? It's not - Jing, kvm_vm_stats_header is small enough that you can store a copy in struct kvm. Paolo From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Date: Thu, 17 Jun 2021 11:23:35 +0000 Subject: Re: [PATCH v10 2/5] KVM: stats: Add fd-based API to read binary stats data Message-Id: List-Id: References: <20210617044146.2667540-1-jingzhangos@google.com> <20210617044146.2667540-3-jingzhangos@google.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Greg KH , Jing Zhang Cc: KVM , KVMARM , LinuxMIPS , KVMPPC , LinuxS390 , Linuxkselftest , Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Will Deacon , Huacai Chen , Aleksandar Markovic , Thomas Bogendoerfer , Paul Mackerras , Christian Borntraeger , Janosch Frank , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Sean Christopherson , Vitaly Kuznetsov , Jim Mattson , Peter Shier , Oliver Upton , David Rientjes , Emanuele Giuseppe Esposito , David Matlack , Ricardo Koller , Krish Sadhukhan , Fuad Tabba On 17/06/21 09:03, Greg KH wrote: >> 3. Fd-based solution provides the possibility that a telemetry can >> read KVM stats in a less privileged situation. > "possiblity"? Does this work or not? Have you tested it? > I think this is essentially s/that/for/. But more precisely: 3. Compared for example to a ioctl, a separate file descriptor makes it possible for an external program to read statistics, while maintaining privilege separation between VMM and telemetry code. >> >> + snprintf(&kvm_vm_stats_header.id[0], sizeof(kvm_vm_stats_header.id), >> + "kvm-%d", task_pid_nr(current)); > > Why do you write to this static variable for EVERY read? Shouldn't you > just do it once at open? How can it change? > > Wait, it's a single shared variable, what happens when multiple tasks > open this thing and read from it? You race between writing to this > variable here and then: > >> + return kvm_stats_read(&kvm_vm_stats_header, &kvm_vm_stats_desc[0], >> + &kvm->stat, sizeof(kvm->stat), user_buffer, size, offset); > > Accessing it here. > > So how is this really working? It's not - Jing, kvm_vm_stats_header is small enough that you can store a copy in struct kvm. Paolo