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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C35F3C433EF for ; Wed, 9 Mar 2022 01:08:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230498AbiCIBJo (ORCPT ); Tue, 8 Mar 2022 20:09:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230501AbiCIBJc (ORCPT ); Tue, 8 Mar 2022 20:09:32 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1F9414ACB0 for ; Tue, 8 Mar 2022 16:51:50 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id p17so586755plo.9 for ; Tue, 08 Mar 2022 16:51:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=2kU1A0mZ+Yf718gi2yxK3phVn7nYLq00SbSALiBBt2c=; b=a3wxXsXXiZ50ZckVfXFMr8KdVU78K5T3RLsMnlj3KUTmsXr2mTTchwj6lfSmoIW6Jw Xxcj7nT6ioNm+beNeT7w/gpTTEoesAjFfDTQkbfIWQwfq91ifPoOm3HZ8d5QpMlRFFmu /SvS/C3P+W10CB6HG+SZCcWMlW7qlD0MjWDZHoph8a3b1v7eqS2BfyKguOEWwdkttbdX RqHb2uCJ+bspxUluBYFhwxvdHNOj0fFpnkuHxLzLPAlkPVyOzDfrRkJ8/tz488d1UDi3 MOfKNkuD4sJ9Xv7tvkhmywY4CjEK6CRMke81P29RSspDH8NnokaenIYa9TIs71rPiZ4j hzYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=2kU1A0mZ+Yf718gi2yxK3phVn7nYLq00SbSALiBBt2c=; b=FscnLH7nZMmg4NoXnLcTC0eaaOVoOkOpShHCEHwc7dLfOGwf3lQ/1vPNOeOpVTu49j EHZckVrlcPPsTnb3IM6MTHjkz6y/nYJz/EB7ibzkooAOI6cIZC7Ian2/8QPJn9KTJyIh XWL5HcSwKENfmI1rXV/lD/ElA+hpPId6YqcOPFqSoiO+HN3xQiLwNudPSxrd3mNtIEuP KcMDDPbx1mLAKrjr7Mg3BViXfiNxIPmUlpCaOY+Yqvu0XTb/VTS5bfS8oW5fEv9T9/Wk rk+ofmCWwT5awDUFF38C9kr06j/NMA3eoSBwbzaDRuww39vKNZAFLgrLZdRDE08FH/mH PJrw== X-Gm-Message-State: AOAM531qnLUyt7CjD7SFcAi1yLWFLG+TxANYGGHO0ugmUI7a74Okauuf 7T9wF2LUd1QX/NBMuHAfc22hSiXfdAV7/A== X-Google-Smtp-Source: ABdhPJxu5BNOL66aUTFVR0ibkfjQAJZxN1/5Jln5I65fELTDrubmqTQaTFywu9mFnXzUzDH+EMVzEQ== X-Received: by 2002:a17:902:b602:b0:14f:e42b:d547 with SMTP id b2-20020a170902b60200b0014fe42bd547mr19779057pls.91.1646782670904; Tue, 08 Mar 2022 15:37:50 -0800 (PST) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id e13-20020a056a001a8d00b004f0f28910cdsm185636pfv.42.2022.03.08.15.37.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 15:37:50 -0800 (PST) Date: Tue, 8 Mar 2022 23:37:46 +0000 From: Sean Christopherson To: Maxim Levitsky Cc: kvm@vger.kernel.org, Kieran Bingham , Jan Kiszka , Andrew Jones , Jonathan Corbet , Vitaly Kuznetsov , Ingo Molnar , Thomas Gleixner , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Johannes Berg , Wanpeng Li , "H. Peter Anvin" , Jessica Yu , Jim Mattson , Paolo Bonzini , Joerg Roedel , Yang Weijiang , linux-kernel@vger.kernel.org, Borislav Petkov , "open list:KERNEL SELFTEST FRAMEWORK" , "open list:DOCUMENTATION" , Shuah Khan , Andrew Morton , Borislav Petkov Subject: Re: [PATCH v3 2/6] KVM: x86: add force_intercept_exceptions_mask Message-ID: References: <20210811122927.900604-1-mlevitsk@redhat.com> <20210811122927.900604-3-mlevitsk@redhat.com> <0cdac80177eea408b7e316bd1fc4c0c5839ba1d4.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0cdac80177eea408b7e316bd1fc4c0c5839ba1d4.camel@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org On Tue, Feb 08, 2022, Maxim Levitsky wrote: > On Thu, 2021-09-02 at 16:56 +0000, Sean Christopherson wrote: > > Assuming this hasn't been abandoned... > > > > On Wed, Aug 11, 2021, Maxim Levitsky wrote: > > > This parameter will be used by VMX and SVM code to force > > > interception of a set of exceptions, given by a bitmask > > > for guest debug and/or kvm debug. > > > > > > This is based on an idea first shown here: > > > https://patchwork.kernel.org/project/kvm/patch/20160301192822.GD22677@pd.tnic/ > > > > > > CC: Borislav Petkov > > > Signed-off-by: Maxim Levitsky > > > --- > > > arch/x86/kvm/x86.c | 3 +++ > > > arch/x86/kvm/x86.h | 2 ++ > > > 2 files changed, 5 insertions(+) > > > > > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > > > index fdc0c18339fb..092e2fad3c0d 100644 > > > --- a/arch/x86/kvm/x86.c > > > +++ b/arch/x86/kvm/x86.c > > > @@ -184,6 +184,9 @@ module_param(force_emulation_prefix, bool, S_IRUGO); > > > int __read_mostly pi_inject_timer = -1; > > > module_param(pi_inject_timer, bint, S_IRUGO | S_IWUSR); > > > > > > +uint force_intercept_exceptions_mask; > > > +module_param(force_intercept_exceptions_mask, uint, S_IRUGO | S_IWUSR); > > > > Use octal permissions. This also can't be a simple writable param, at least not > > without a well-documented disclaimer, as there's no guarantee a vCPU will update > > its exception bitmap in a timely fashion. An alternative to a module param would > > be to extend/add a per-VM ioctl(), e.g. maybe KVM_SET_GUEST_DEBUG? The downside > > of an ioctl() is that it would require userspace enabling :-/ > > > > All other module params in this file use macros for permissions, that is why > I used them too. > > I'll add a comment with a disclaimer here - this is only for debug. > I strongly don't want to have this as ioctl as that will indeed need qemu patches, > not to mention things like unit tests and which don't even always use qemu. > > Or I can make this parameter read-only. I don't mind reloading kvm module when > I change this parameter. Oh! We can force an update, a la nx_huge_pages, where the setter loops through all VMs and does a kvm_make_all_cpus_request() to instruct vCPUs to update their bitmaps. Requires a new request, but that doesn't seem like a huge deal, and it might help pave the way for adding more debug hooks for developers. The param should also be "unsafe". E.g. something like static const struct kernel_param_ops force_ex_intercepts_ops = { .set = set_force_exception_intercepts, .get = get_force_exception_intercepts, }; module_param_cb_unsafe(force_exception_intercepts, &force_ex_intercepts_ops, &force_exception_intercepts, 0644);