From patchwork Fri Jan 31 17:49:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11360325 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3B883924 for ; Fri, 31 Jan 2020 17:50:49 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 17E322082E for ; Fri, 31 Jan 2020 17:50:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="k7BWOimr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 17E322082E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ixaQH-0005qy-HT; Fri, 31 Jan 2020 17:49:41 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ixaQG-0005qs-J9 for xen-devel@lists.xenproject.org; Fri, 31 Jan 2020 17:49:40 +0000 X-Inumbo-ID: 0ca14fc6-4452-11ea-8396-bc764e2007e4 Received: from mail-wm1-x341.google.com (unknown [2a00:1450:4864:20::341]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0ca14fc6-4452-11ea-8396-bc764e2007e4; Fri, 31 Jan 2020 17:49:38 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id g1so8887480wmh.4 for ; Fri, 31 Jan 2020 09:49:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Egz3txqQqthBIsSjMFQvj77WUNoiga8Y7f7moMDL01Y=; b=k7BWOimru4Z0jLixjjuChh/KfxXDiHXFwlyGTZCdeeMM/cY7aO3HuZKJDWxehvy/6f mT6JY2/f3/RHYrE26+lssizf58LUauU1CJwXjV7KhCLKsQCCfp62jwgiHAebM5buGeK7 jdLsosIg0fuKO8vJrViGYT+7Y0OK5XnWuNlpSnD4LWZ7C+VNM3/+rpqeAIu/anfdYHwy /jE0tzIeCBzHz1baudJdnyqvaYtOMBjpfo/ijVwYJA6oR1YyLLqh5MzhJj2bcv4s3Vjs O5W5krRLBgue/SwwLAkOe/DVHOPRzXn7XdN6MfoRo1yiSSE2kP4V+r0tS+pr7Aexi4UU A5yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Egz3txqQqthBIsSjMFQvj77WUNoiga8Y7f7moMDL01Y=; b=YU3Bg/ksqmISiZAm5Z5dC13Xca60lf4vNqoIOmWhSi+7ZBEt6evbrrCbYx0dGdwAdD tysid0eo8+jpGXqv4b6LaiWDvEJcF1RQa5BjNpek/twlla6lPwwK3AdE01tXdWridQNo dMMmuTp8NIUNuXmHVmt+zRDy5/RWhN7KK9kNu5YNImaGbb3qyBq6nxqqcVVFrUFXW3CX AprhKSkDmOG0Ze4TfqYeOe4PyNgnnQ/Yq/DrLl4xQWGcIew8LFjLxWNbb9T/umBrDXcb xSlnmlB8FaZKy1hiESHFpVu7Hdj3DoCPTZ8SY/VAyLYxVhi9PmLp2ovB4UBFUIxaUfu/ R2AQ== X-Gm-Message-State: APjAAAWMAUE1u30edrJ7WEsDyDE33Xx8nant7cSmKfl5+32esNwbYPEw /rmwPj3o/+zAtfG7vKgv98HeRtHyRmE= X-Google-Smtp-Source: APXvYqxRfBxG1yOxDUs3O2IOTU1WaablLfIjYKWavDKt/1y04+C0B3L4gvoN/as1Yh6/4ZwutiJyWg== X-Received: by 2002:a1c:1b42:: with SMTP id b63mr13481018wmb.16.1580492974801; Fri, 31 Jan 2020 09:49:34 -0800 (PST) Received: from localhost.localdomain (41.142.6.51.dyn.plus.net. [51.6.142.41]) by smtp.gmail.com with ESMTPSA id 133sm4364352wmd.5.2020.01.31.09.49.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jan 2020 09:49:34 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Fri, 31 Jan 2020 17:49:20 +0000 Message-Id: <20200131174930.31045-2-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200131174930.31045-1-liuwe@microsoft.com> References: <20200131174930.31045-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v6 01/11] x86/hypervisor: make hypervisor_ap_setup return an error code X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Wei Liu , Andrew Cooper , Paul Durrant , Michael Kelley , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" We want to be able to handle AP setup error in the upper layer. Signed-off-by: Wei Liu --- v6: 1. Change map_vcpuinfo as well 2. Make code shorter --- xen/arch/x86/guest/hypervisor.c | 6 ++++-- xen/arch/x86/guest/xen/xen.c | 24 +++++++++++++++--------- xen/include/asm-x86/guest/hypervisor.h | 6 +++--- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hypervisor.c index 4f27b98740..e72c92ffdf 100644 --- a/xen/arch/x86/guest/hypervisor.c +++ b/xen/arch/x86/guest/hypervisor.c @@ -52,10 +52,12 @@ void __init hypervisor_setup(void) ops->setup(); } -void hypervisor_ap_setup(void) +int hypervisor_ap_setup(void) { if ( ops && ops->ap_setup ) - ops->ap_setup(); + return ops->ap_setup(); + + return 0; } void hypervisor_resume(void) diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c index 6dbc5f953f..d50f86bae7 100644 --- a/xen/arch/x86/guest/xen/xen.c +++ b/xen/arch/x86/guest/xen/xen.c @@ -113,16 +113,16 @@ static int map_vcpuinfo(void) info.mfn = virt_to_mfn(&vcpu_info[vcpu]); info.offset = (unsigned long)&vcpu_info[vcpu] & ~PAGE_MASK; rc = xen_hypercall_vcpu_op(VCPUOP_register_vcpu_info, vcpu, &info); - if ( rc ) - { - BUG_ON(vcpu >= XEN_LEGACY_MAX_VCPUS); - this_cpu(vcpu_info) = &XEN_shared_info->vcpu_info[vcpu]; - } - else + if ( !rc ) { this_cpu(vcpu_info) = &vcpu_info[vcpu]; set_bit(vcpu, vcpu_info_mapped); } + else if ( vcpu < XEN_LEGACY_MAX_VCPUS ) + { + rc = 0; + this_cpu(vcpu_info) = &XEN_shared_info->vcpu_info[vcpu]; + } return rc; } @@ -257,11 +257,17 @@ static void __init setup(void) init_evtchn(); } -static void ap_setup(void) +static int ap_setup(void) { + int rc; + set_vcpu_id(); - map_vcpuinfo(); - init_evtchn(); + rc = map_vcpuinfo(); + + if ( !rc ) + init_evtchn(); + + return rc; } int xg_alloc_unused_page(mfn_t *mfn) diff --git a/xen/include/asm-x86/guest/hypervisor.h b/xen/include/asm-x86/guest/hypervisor.h index 392f4b90ae..b503854c5b 100644 --- a/xen/include/asm-x86/guest/hypervisor.h +++ b/xen/include/asm-x86/guest/hypervisor.h @@ -25,7 +25,7 @@ struct hypervisor_ops { /* Main setup routine */ void (*setup)(void); /* AP setup */ - void (*ap_setup)(void); + int (*ap_setup)(void); /* Resume from suspension */ void (*resume)(void); }; @@ -34,7 +34,7 @@ struct hypervisor_ops { const char *hypervisor_probe(void); void hypervisor_setup(void); -void hypervisor_ap_setup(void); +int hypervisor_ap_setup(void); void hypervisor_resume(void); #else @@ -44,7 +44,7 @@ void hypervisor_resume(void); static inline const char *hypervisor_probe(void) { return NULL; } static inline void hypervisor_setup(void) { ASSERT_UNREACHABLE(); } -static inline void hypervisor_ap_setup(void) { ASSERT_UNREACHABLE(); } +static inline int hypervisor_ap_setup(void) { ASSERT_UNREACHABLE(); return 0; } static inline void hypervisor_resume(void) { ASSERT_UNREACHABLE(); } #endif /* CONFIG_GUEST */