From nobody Fri Jan 3 03:48:26 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1728376764; cv=none; d=zohomail.com; s=zohoarc; b=O0O4jDFlxDoEWyZ9b5+fPSsKa9j850HeqChwmUkrI2z1rhrVIzoNDopaodGsCHKYOrVBr+NCxwG03mBNlroz9xnM3KDJgZKfQwLsLWB4M5T8XTqN2CvdhVZ2Tb0ane4UDvUyECEDal81I+x69GbTSyciWlYixddoQ+jR4Zd5O98= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728376764; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XH4xpZLptCZ6C2dJ+MYc8/xilU4dhsL/mNlDZC0yzNk=; b=YtmZEtIcAgVU2TVk3mLHWT2N7J1fZfVJLPJJcLEd/xu9EQSi0HjuEVrNDA8SSrkPFc0lXpfjDq/oT/ibF58au9LUzy2ET1FMZLnnDwIUxPaW6JLnboyb3xZMbAn8ufm7Uk9w5KEMULXhjtoYZmOSFrLjyk3U9SOxhJwF7OrlldI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1728376764984657.3594716565663; Tue, 8 Oct 2024 01:39:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.812815.1225575 (Exim 4.92) (envelope-from ) id 1sy5kK-0003Og-0a; Tue, 08 Oct 2024 08:39:08 +0000 Received: by outflank-mailman (output) from mailman id 812815.1225575; Tue, 08 Oct 2024 08:39:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sy5kJ-0003OZ-To; Tue, 08 Oct 2024 08:39:07 +0000 Received: by outflank-mailman (input) for mailman id 812815; Tue, 08 Oct 2024 08:39:07 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sy5kJ-00027a-7s for xen-devel@lists.xenproject.org; Tue, 08 Oct 2024 08:39:07 +0000 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [2a00:1450:4864:20::635]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c7ae4b40-8550-11ef-a0bc-8be0dac302b0; Tue, 08 Oct 2024 10:39:06 +0200 (CEST) Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a93c1cc74fdso889699466b.3 for ; Tue, 08 Oct 2024 01:39:06 -0700 (PDT) Received: from localhost ([213.195.117.215]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a994d5fbef4sm301560066b.166.2024.10.08.01.39.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 01:39:05 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: c7ae4b40-8550-11ef-a0bc-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1728376746; x=1728981546; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=XH4xpZLptCZ6C2dJ+MYc8/xilU4dhsL/mNlDZC0yzNk=; b=kSgi0ZIQqibYtdaZZlOL8sNO1DIH5psPg13h+LVk3knD59zNI0KVaO+Mjm0EV8LX46 QZTKPiLr1iGWRdvqW7YeNMBPmd6yfaTI0iyoZ2EXx0hSBAClOD7PGwrX6G1Q9Lw6X0VM Bh3ue62A/o7d6cZnYpN3ZW5bilf/upNGPvfq0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728376746; x=1728981546; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XH4xpZLptCZ6C2dJ+MYc8/xilU4dhsL/mNlDZC0yzNk=; b=o+bf1ClzW5ROpwmRuk9iJXSrneiB/6PGd0nv8tdp4e6rgAWnbOc7jI6WA9puaMhSzd v+pu06NnuKTXk+g1XsvvKW8tjC5nL4NVCKLZFoOlb98kYSE+bskSpCg0HJkDZIvbJCpS e0U+qmfnLiCTlfBzMBSeUlEyc7pkbIa7ySZPnbc8+l3s+jHw3tfBNLIMvmQ9Hp+qfP3a PH34rTB8JDSicANOHMHEDnFF0IJ1dXAcuxLSKhGI9nrbL9nnHFvoZKBu0XxjQsU9V5O4 3Pjd+kuDus1IMeri6HJPexVnpJzZ/xOydO+Rg/dqMtrQ/sU+qFXOHGjplPV+Lljs0RXr 0oOg== X-Gm-Message-State: AOJu0YzlgsMcEH2J7zd0IuRa5+hUkHjRYYYycNUEVu7OrLa/b4mTNa2w Ym+KOrvDM3jR9H3UdEr3xpzzMkYmuL3qYp87oJWbckmM4pWZh7xDpgGGbSBLolY37j1VF7X0xH8 8 X-Google-Smtp-Source: AGHT+IEiTqV0Z7Wc62OgQfur6LtB6ahmdwOUDQuXTFad+6bufrugr/W2oDUY0dDzNfEND/ix/rixlQ== X-Received: by 2002:a17:907:6095:b0:a99:46ff:f4e6 with SMTP id a640c23a62f3a-a9947000935mr927692166b.61.1728376745825; Tue, 08 Oct 2024 01:39:05 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper Subject: [PATCH v2] x86/msr: add log messages to MSR state load error paths Date: Tue, 8 Oct 2024 10:39:01 +0200 Message-ID: <20241008083901.72850-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1728376766344116600 Some error paths in the MSR state loading logic don't contain error message= s, which makes debugging them quite hard without adding extra patches to print= the information. Add two new log messages to the MSR state load path that print information about the entry that failed to load, for both PV and HVM. While there also adjust XEN_DOMCTL_set_vcpu_msrs to return -ENXIO in case t= he MSR is unhandled or can't be loaded, so it matches the error code used by H= VM MSR loading (and it's less ambiguous than -EINVAL). Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Jan Beulich --- Changes since v1: - Add messages to PV MSR loading. - Return -ENXIO from PV loading path also. - Do not print the return code from guest_wrmsr(), it's not specially help= ful given the current logic, as it will always be X86EMUL_EXCEPTION in case = of failure. --- xen/arch/x86/domctl.c | 8 ++++++++ xen/arch/x86/hvm/hvm.c | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index 96d816cf1a7d..f76de5be9437 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -1166,6 +1166,7 @@ long arch_do_domctl( if ( msr.reserved ) break; =20 + ret =3D -ENXIO; switch ( msr.index ) { case MSR_SPEC_CTRL: @@ -1174,9 +1175,16 @@ long arch_do_domctl( case MSR_AMD64_DR0_ADDRESS_MASK: case MSR_AMD64_DR1_ADDRESS_MASK ... MSR_AMD64_DR3_ADDRESS_= MASK: if ( guest_wrmsr(v, msr.index, msr.value) !=3D X86EMUL= _OKAY ) + { + printk(XENLOG_G_ERR + "%pv load MSR %#x with value %#lx failed\n", + v, msr.index, msr.value); break; + } continue; } + printk(XENLOG_G_ERR "%pv attempted load of unhandled MSR %= #x\n", + v, msr.index); break; } =20 diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 69a25571db8d..200f0a414138 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1598,10 +1598,17 @@ static int cf_check hvm_load_cpu_msrs(struct domain= *d, hvm_domain_context_t *h) rc =3D guest_wrmsr(v, ctxt->msr[i].index, ctxt->msr[i].val); =20 if ( rc !=3D X86EMUL_OKAY ) + { + printk(XENLOG_G_ERR + "HVM %pv load MSR %#x with value %#lx failed\n", + v, ctxt->msr[i].index, ctxt->msr[i].val); return -ENXIO; + } break; =20 default: + printk(XENLOG_G_ERR "HVM %pv attempted load of unhandled MSR %= #x\n", + v, ctxt->msr[i].index); return -ENXIO; } } --=20 2.46.0