From patchwork Fri May 15 14:27:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 48568 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A33862121F for ; Fri, 15 May 2015 14:28:52 +0000 (UTC) Received: by wizk4 with SMTP id k4sf35388346wiz.2 for ; Fri, 15 May 2015 07:28:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=6A57/UP8FStToAZqUJnuwA6mxYe+ElL+X0c4ePNo7Yw=; b=ljWU+4ZPqGijpZauN4jrQAp0QyVdTiwIyTDUKuaATnbQ/wfIYYGSQB+8RHjgQqbl+N jo/5fJkvFen8QIrJme6blZmHMrM1aYCegpZ0lSBs36VxzUKSqlgZo2gaN5RNBRgeA9oe y4aS3/6Toj84/MGMNvcsje8hH2m+A34AVwj7Ni9AcbloJdst0wjko6QUwH2S6rdgKpqS FSytQDFCJmC4ja0zT1gzTQg3TZ99rvUZzfiqp6fI6bLd91V7ZcXVL+/CP72eoD/KV17G fETed5iY79vCRTTshsrnVsmb6A/vxOhofrR61D3Jfg0v42/FbRtuaJVKqxlusROmbHq6 Yt2Q== X-Gm-Message-State: ALoCoQmw3sJ4VrbXHBNboZXnADqa1aSGyrzRgr0UwTjKEnQD3U5fl5XXsdVdN3Fm6VR7GqPzGko0 X-Received: by 10.112.160.197 with SMTP id xm5mr7175080lbb.15.1431700131687; Fri, 15 May 2015 07:28:51 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.40 with SMTP id v8ls499802laj.88.gmail; Fri, 15 May 2015 07:28:51 -0700 (PDT) X-Received: by 10.112.222.133 with SMTP id qm5mr7438156lbc.86.1431700131442; Fri, 15 May 2015 07:28:51 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id i2si1165128lam.72.2015.05.15.07.28.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 May 2015 07:28:51 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by lagv1 with SMTP id v1so122099025lag.3 for ; Fri, 15 May 2015 07:28:51 -0700 (PDT) X-Received: by 10.152.4.72 with SMTP id i8mr7595933lai.32.1431700131042; Fri, 15 May 2015 07:28:51 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp2077041lbb; Fri, 15 May 2015 07:28:49 -0700 (PDT) X-Received: by 10.68.213.135 with SMTP id ns7mr18794836pbc.157.1431700129148; Fri, 15 May 2015 07:28:49 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y10si2869429pdn.1.2015.05.15.07.28.19; Fri, 15 May 2015 07:28:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933991AbbEOO1M (ORCPT + 28 others); Fri, 15 May 2015 10:27:12 -0400 Received: from static.88-198-71-155.clients.your-server.de ([88.198.71.155]:36176 "EHLO socrates.bennee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754954AbbEOO1I (ORCPT ); Fri, 15 May 2015 10:27:08 -0400 Received: from localhost ([127.0.0.1] helo=zen.linaroharston) by socrates.bennee.com with esmtp (Exim 4.80) (envelope-from ) id 1YtHqK-0000D4-4J; Fri, 15 May 2015 17:48:08 +0200 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org, marc.zyngier@arm.com, peter.maydell@linaro.org, agraf@suse.de, drjones@redhat.com, pbonzini@redhat.com, zhichao.huang@linaro.org Cc: jan.kiszka@siemens.com, dahi@linux.vnet.ibm.com, r65777@freescale.com, bp@suse.de, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Gleb Natapov , Jonathan Corbet , Russell King , linux-doc@vger.kernel.org (open list:DOCUMENTATION), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 04/12] KVM: arm: guest debug, add stub KVM_SET_GUEST_DEBUG ioctl Date: Fri, 15 May 2015 15:27:07 +0100 Message-Id: <1431700035-23479-5-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.3.5 In-Reply-To: <1431700035-23479-1-git-send-email-alex.bennee@linaro.org> References: <1431700035-23479-1-git-send-email-alex.bennee@linaro.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: alex.bennee@linaro.org X-SA-Exim-Scanned: No (on socrates.bennee.com); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: alex.bennee@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This commit adds a stub function to support the KVM_SET_GUEST_DEBUG ioctl. Any unsupported flag will return -EINVAL. For now, only KVM_GUESTDBG_ENABLE is supported, although it won't have any effects. Signed-off-by: Alex Bennée . Reviewed-by: Christoffer Dall --- v2 - simplified form of the ioctl (stuff will go into setup_debug) v3 - KVM_GUESTDBG_VALID->KVM_GUESTDBG_VALID_MASK - move mask check to the top of function - add ioctl doc header - split capability into separate patch - tweaked commit wording w.r.t return of -EINVAL v4 - add r-b-tag diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt index c34c32d..ba635c7 100644 --- a/Documentation/virtual/kvm/api.txt +++ b/Documentation/virtual/kvm/api.txt @@ -2645,7 +2645,7 @@ handled. 4.87 KVM_SET_GUEST_DEBUG Capability: KVM_CAP_SET_GUEST_DEBUG -Architectures: x86, s390, ppc +Architectures: x86, s390, ppc, arm64 Type: vcpu ioctl Parameters: struct kvm_guest_debug (in) Returns: 0 on success; -1 on error diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index d9631ec..52a1d4d38 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -302,10 +302,31 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) kvm_arm_set_running_vcpu(NULL); } +#define KVM_GUESTDBG_VALID_MASK (KVM_GUESTDBG_ENABLE) + +/** + * kvm_arch_vcpu_ioctl_set_guest_debug - set up guest debugging + * @kvm: pointer to the KVM struct + * @kvm_guest_debug: the ioctl data buffer + * + * This sets up and enables the VM for guest debugging. Userspace + * passes in a control flag to enable different debug types and + * potentially other architecture specific information in the rest of + * the structure. + */ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu, struct kvm_guest_debug *dbg) { - return -EINVAL; + if (dbg->control & ~KVM_GUESTDBG_VALID_MASK) + return -EINVAL; + + if (dbg->control & KVM_GUESTDBG_ENABLE) { + vcpu->guest_debug = dbg->control; + } else { + /* If not enabled clear all flags */ + vcpu->guest_debug = 0; + } + return 0; }