From patchwork Tue Jun 18 16:00:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 805250 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:144:b0:362:4979:7f74 with SMTP id r4csp274980wrx; Tue, 18 Jun 2024 09:09:40 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVECBT7Ktmk7Smt3CDDYOEhPtMZFbcehYA7GCA0uB0XqA1oM0gf6fKgoU6QuGL5Bh6yppal/MyAzpEQM4mNiL/L X-Google-Smtp-Source: AGHT+IHYNNctfmwCHRynNII2XZC1sfoF9iwg/gE645ivtULs3HJPZ0RG4WSXgr1gQ2o5mBw4DEuE X-Received: by 2002:a05:620a:3906:b0:795:36b8:24ca with SMTP id af79cd13be357-79bb3e3d709mr16595485a.21.1718726979891; Tue, 18 Jun 2024 09:09:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718726979; cv=none; d=google.com; s=arc-20160816; b=FHcH8o2eTQCkss2uw0U9uTVTI+J5KB+D75PQI4ICQ1FWvX+gGl/sfS64tQDpRRPEUN b7AX3g3//3UjGDLWmDahtSeMthHAZztimj+7Gwlr8UiaV4igQ8zxEcwFkvl1QIYvStbP gqJ2LTo61xmPzDAd8xW/qIC5fIfMVij13WeeRyO4Sy+Xx/mPgPGrWhHWuvAmmWSqw+5u DeK5SMGWQoAz0/CHoyEWLUdBSML8+FEjwe77Atgik0chgsbokHrY0+U+IC3xGQ3eMy2a rCKXhCoZL1g8Ca7T9JlavTfkHbKwTyW94l7i7UoldLoRifqeUFll/dY1uUMX7YDVe9n7 LWLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hkNlA20kHSDOIhmvlUTbRhNSgQ9/ouK3bJTAy3+65gs=; fh=7pAJ/JzK0JeXy9rTMidVcRJ/xp+yDkh4jef9lXv4k6c=; b=vmQbh1eOFRFOKw6sdX2YfhwZmzHJIE/vD7/mBX4kXAfC5wE9HVknvF3JVCJcHasNWe BS1lDO5PxY5CGD9k+IG92mXKb8dvQvr5aG+9XyRZAt5I+dbGBOqOkvcYCJ9EKjf40dea S0XVqobQHyOUQluUDjzESu28zRrtRI8r6q+WEYkP+11sGv8tpnFHs/mRLBBLT6hygS21 j+/Y1WdG6f5UtVFKg6/XeqRZw2xipwgW2Xh0NZJTBmaaQ4ymzZhXq59sra4s1gZNKRZk hc2wvEXcm7wft7kDHvlEVBxVYpzq70ozSc9CsGPJiWSKHLFx6TgbANz7luKHXlPh0dNC f3cQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="K7mxt/1d"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-441f2fddb8esi135594011cf.518.2024.06.18.09.09.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Jun 2024 09:09:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="K7mxt/1d"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJbMT-0001YD-8P; Tue, 18 Jun 2024 12:07:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJbMR-0001H7-4u for qemu-devel@nongnu.org; Tue, 18 Jun 2024 12:07:07 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJbMO-0007uG-VW for qemu-devel@nongnu.org; Tue, 18 Jun 2024 12:07:06 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-35f236a563cso4389520f8f.2 for ; Tue, 18 Jun 2024 09:07:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718726822; x=1719331622; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hkNlA20kHSDOIhmvlUTbRhNSgQ9/ouK3bJTAy3+65gs=; b=K7mxt/1dw2SasnYObYDz1LqPBxiGDT7KbiimwIS9whMbTdkxl2hhvWLpZ8ug2nujR9 KTnU5mhDCyCIXF1mEzDKdBhSOxgi01gGHrwWMIVuda/m0tLkoiLnw+ZFGnmqFLhsHifK tiBJ4+NRNcP3WK4X22XhO8C5B1lMKo5a4S3vVtKcOthpIz4wOxG25GxL1fJ//fMy1Xt9 +bgqMN0wyJRI65LFEmRKCuDPQCgZzdjOuRFE93XnoFeYThKdu13XYnaLeD5xirmEKIZG xBVsAaVda7EwZn4e8oWRwseG+bC+osD3VKm5ee0ZOI3hRIVxga5jt7eQcQBm4XtWylvx Nz8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718726822; x=1719331622; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hkNlA20kHSDOIhmvlUTbRhNSgQ9/ouK3bJTAy3+65gs=; b=mOhDDsJv5cutSfpq0ydJeyBpjjprXT2XyRZBIZ7omzrTfccddVcfSf9E/9MPyMC7M7 X7VGf/BhOZy5JjE9cEQnp9x3kofcseD3wZxmlEvM4HxyBv9Fa2L9Amkn/f1jmWrkoE+6 tOKBH5/YtugpGo/XDAQomZ+4C+j64esfSQ77xlfOF2daJ750OFi/uMEACJcueIIXWJ1d h/qOBN0no1Wht2kIUR81WDFuZfy/kcV8ahao73Wzt0PsY/tN4bQhrwQmPUMr0t7p4Ac7 z3oZ4guHeT6CxTrmxuCjZJxk4mhV+fTbGiNpwVhWjVqo9RxsclfFC1mCzwudF7QycUoz AcAg== X-Gm-Message-State: AOJu0YxuHucdRsftwQsvMX6zcui8glP28TdWLtx6W+6vKLJjdV8HdvVs C8T9nkzEVad+wDt/9fF3wZTyLOyFVtncsczH4aEi9Zn8xpVVTUWucwt2jNWl2TDpweRZafuv0jb 8 X-Received: by 2002:a05:6000:104:b0:35f:2774:9c2f with SMTP id ffacd0b85a97d-363192d07bcmr16723f8f.49.1718726822753; Tue, 18 Jun 2024 09:07:02 -0700 (PDT) Received: from m1x-phil.lan ([176.187.212.55]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3607a43eedfsm12693341f8f.78.2024.06.18.09.07.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 18 Jun 2024 09:07:02 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Thomas Huth , Paolo Bonzini Subject: [PULL 66/76] hw/s390x: Introduce s390_skeys_get|set() helpers Date: Tue, 18 Jun 2024 18:00:28 +0200 Message-ID: <20240618160039.36108-67-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240618160039.36108-1-philmd@linaro.org> References: <20240618160039.36108-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=philmd@linaro.org; helo=mail-wr1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org s390_skeys_set() dispatch to S390SKeysClass::set_skeys(), and s390_skeys_get() to S390SKeysClass::get_skeys(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth Reviewed-by: Paolo Bonzini Message-Id: <20240613104415.9643-2-philmd@linaro.org> --- include/hw/s390x/storage-keys.h | 10 ++++++++++ hw/s390x/s390-skeys.c | 27 +++++++++++++++++++++++++++ hw/s390x/trace-events | 4 ++++ 3 files changed, 41 insertions(+) diff --git a/include/hw/s390x/storage-keys.h b/include/hw/s390x/storage-keys.h index aa2ec2aae5..976ffb2039 100644 --- a/include/hw/s390x/storage-keys.h +++ b/include/hw/s390x/storage-keys.h @@ -111,6 +111,16 @@ struct QEMUS390SKeysState { }; void s390_skeys_init(void); +/** + * @s390_skeys_get: See S390SKeysClass::get_skeys() + */ +int s390_skeys_get(S390SKeysState *ks, uint64_t start_gfn, + uint64_t count, uint8_t *keys); +/** + * @s390_skeys_set: See S390SKeysClass::set_skeys() + */ +int s390_skeys_set(S390SKeysState *ks, uint64_t start_gfn, + uint64_t count, uint8_t *keys); S390SKeysState *s390_get_skeys_device(void); diff --git a/hw/s390x/s390-skeys.c b/hw/s390x/s390-skeys.c index 5c535d483e..bf22d6863e 100644 --- a/hw/s390x/s390-skeys.c +++ b/hw/s390x/s390-skeys.c @@ -23,6 +23,7 @@ #include "sysemu/kvm.h" #include "migration/qemu-file-types.h" #include "migration/register.h" +#include "trace.h" #define S390_SKEYS_BUFFER_SIZE (128 * KiB) /* Room for 128k storage keys */ #define S390_SKEYS_SAVE_FLAG_EOS 0x01 @@ -54,6 +55,32 @@ void s390_skeys_init(void) qdev_realize(DEVICE(obj), NULL, &error_fatal); } +int s390_skeys_get(S390SKeysState *ks, uint64_t start_gfn, + uint64_t count, uint8_t *keys) +{ + S390SKeysClass *kc = S390_SKEYS_GET_CLASS(ks); + int rc; + + rc = kc->get_skeys(ks, start_gfn, count, keys); + if (rc) { + trace_s390_skeys_get_nonzero(rc); + } + return rc; +} + +int s390_skeys_set(S390SKeysState *ks, uint64_t start_gfn, + uint64_t count, uint8_t *keys) +{ + S390SKeysClass *kc = S390_SKEYS_GET_CLASS(ks); + int rc; + + rc = kc->set_skeys(ks, start_gfn, count, keys); + if (rc) { + trace_s390_skeys_set_nonzero(rc); + } + return rc; +} + static void write_keys(FILE *f, uint8_t *keys, uint64_t startgfn, uint64_t count, Error **errp) { diff --git a/hw/s390x/trace-events b/hw/s390x/trace-events index 34da5ea323..4e74bf4484 100644 --- a/hw/s390x/trace-events +++ b/hw/s390x/trace-events @@ -36,3 +36,7 @@ s390_pci_unknown(const char *msg, uint32_t cmd) "%s unknown command 0x%x" s390_pci_bar(uint32_t bar, uint32_t addr, uint64_t size, uint32_t barsize) "bar %d addr 0x%x size 0x%" PRIx64 "barsize 0x%x" s390_pci_nodev(const char *cmd, uint32_t fh) "%s no pci dev fh 0x%x" s390_pci_invalid(const char *cmd, uint32_t fh) "%s invalid space fh 0x%x" + +# s390-skeys.c +s390_skeys_get_nonzero(int rc) "SKEY: Call to get_skeys unexpectedly returned %d" +s390_skeys_set_nonzero(int rc) "SKEY: Call to set_skeys unexpectedly returned %d"