From patchwork Thu Jun 13 10:44:14 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: 803865 Delivered-To: patch@linaro.org Received: by 2002:a5d:58c5:0:b0:35b:5a80:51b4 with SMTP id o5csp239812wrf; Thu, 13 Jun 2024 03:44:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVleDhfCZjdxrlaC0/GCmN5Uph7206BbtNsf0s6ywDc4iiUJ4XgjzdUYu5I/YdMo/ykRpMm3nHlC1fJOo3MIKbu X-Google-Smtp-Source: AGHT+IE4y6izR6t5inflb8/ZaoTa/2iQPKJqD+p1op97OgAwInYSjp9UM416JleXV9DFPlQAV/n3 X-Received: by 2002:a81:a147:0:b0:61a:f206:bad6 with SMTP id 00721157ae682-62fbb412810mr42949017b3.30.1718275490384; Thu, 13 Jun 2024 03:44:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718275490; cv=none; d=google.com; s=arc-20160816; b=CIloAHqDpldEw3QwcX7VSB4VqhiG8hLTvpFaB/NXN/wPkcNVF0XGJaLCUE+EwsZeVq n/f+kCtWfytB3V3pPPhfGJRyJjcyNV460C/VSepYd+cULpLqj2iUlFbsHeg8e3vQjhyt FsvOuROkYw5ViQ75JNwqRO7tbrOe06J7qIQhViebf3e2AA4DQOWwME1PUTuaDU8sVv0a sBMJZDnQf7LY4C0HVIVxQn0GpR8kf9Ry022tChjxWYnD2AByhiTQDUv8pIb9bqavDYUi GljJ8iwRRjlb8jhHBaA6ZWYzyDb1/fGkAiPIXGFH+ZQIW2d+7OinCtfCijIEVSnUj7OF ksmg== 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=9bb2eJ+cyDtCSIGPEF3KqVqxXfOihaXK/Jl7Nmci3es=; fh=xBDq+vw2O4NzhKQlMCAv2ESMCrOs2fHGJ5yzjmHHQ6k=; b=UpEW4DtiWdOot8EtEy1clT29f40sC8IW5THa5/0rbR2b0aBl/vsK0d0eZkY/09mLbQ dEJBNyNYU3fQh0sqINTi66zptM4k967WpRugC2f/kPKg7oAjjRm5FFqacGwqr7L9RPGL DPdm/vw0/k44JCh9tpK4uVi96BGPUoKUgZHqrVdPRF1ST6gNNw3zejj9hgmqjcZQmALA x8Ye+adya5Dz861zdavjPvxTdOwx0ZgZlMLmjOjv/orlU3dRmtp2BAVMYc2QVB/zxEKt BWeOtPRHRDJa2MkvnNn4LBrgLZH65SvJkyLD9hEk1XX+KcpNXL+sX5Kxx/Mpw82vsmif 1ucQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IEm7m0QK; 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 6a1803df08f44-6b2a5b376f7si11621086d6.409.2024.06.13.03.44.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2024 03:44:50 -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=IEm7m0QK; 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 1sHhwU-0005b7-4O; Thu, 13 Jun 2024 06:44:30 -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 1sHhwS-0005aa-MG for qemu-devel@nongnu.org; Thu, 13 Jun 2024 06:44:28 -0400 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sHhwR-0003lL-1l for qemu-devel@nongnu.org; Thu, 13 Jun 2024 06:44:28 -0400 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a6f11a2d18aso112848166b.2 for ; Thu, 13 Jun 2024 03:44:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718275465; x=1718880265; 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=9bb2eJ+cyDtCSIGPEF3KqVqxXfOihaXK/Jl7Nmci3es=; b=IEm7m0QKwNqRAdgGf3g3MU9fwjH3MuZ1czncmcUUHrtl+pibdz5852pyqrei6GouKL tlBPvOe8lHFjNvIN5oPCuSBeCJHN5ww6SN4v6qCh6bCYxRNbuzs3fykJdvxXtstP0Fcx esWPiBP69LKyq87j2HHm5lDYyyz22Hn3bEeJnmYN1Mtw2KnsnjHOMU2zh8xLR6zQtRjL FpApOqg0gNzjRBnkhuY6S+qGMlx4+NG373mq194HIoUzUFAXIuRhLZLj02COpbhTiEeR CvDQU7H0wOCXrpBohmyZG3aftIxskUwJIsNKfU260cbcUcTKs9pCotTg3mCc18jiRLr5 6wJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718275465; x=1718880265; 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=9bb2eJ+cyDtCSIGPEF3KqVqxXfOihaXK/Jl7Nmci3es=; b=dgBoRKKV+macyE7uwSbE+E/yFcT9FS5/8WwWMx36W+YPbWHUyDKhV/Gu8ECEy3zUnx P3ZsyQPeCKHFwYwiwJuYHQrAgCGAsS8d9W2Yyv+vuH5YIE5FjUsMgmYRjM8QnFWj7ndy RSzcSNMfuHFNTC2gVlDAQ2jg+PpyXtw/kjsat3o2toMYUwUp4pH883zBNJe3r+x4SJOq V+YhsnBl0ikbKf56m55WKN7MJS1nyGHq6BjKNy1DrAu0GDluZsWPzjRXyvZXJJt5A9SN NkBkLNhEgAAn1AuBrUXPp3Nz/mdWgM+N4nW7LkLqOFOzdgueY+Ma8RtrJ/2waJP71Chj jRKg== X-Gm-Message-State: AOJu0YzP4G2qro7nBfy0YVQomRyqfVzNBFZUulARQYNxK0xDMZUo89Y1 Hp+9sWbcRauO70Q6OTQWi91ALzd0SthgUfeYVD1H7/vZKS952W/MdCAu5Kmz9evQkG61G/HQf9y 7 X-Received: by 2002:a17:906:489:b0:a6e:7e1f:2eae with SMTP id a640c23a62f3a-a6f4800b167mr270427666b.74.1718275465210; Thu, 13 Jun 2024 03:44:25 -0700 (PDT) Received: from m1x-phil.lan ([176.176.148.226]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f56ed0f2asm58863566b.131.2024.06.13.03.44.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 13 Jun 2024 03:44:24 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eric Farman , Peter Maydell , Halil Pasic , Richard Henderson , David Hildenbrand , qemu-s390x@nongnu.org, Ilya Leoshkevich , Christian Borntraeger , Mark Cave-Ayland , Thomas Huth , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 1/2] hw/s390x: Introduce s390_skeys_get|set() helpers Date: Thu, 13 Jun 2024 12:44:14 +0200 Message-ID: <20240613104415.9643-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240613104415.9643-1-philmd@linaro.org> References: <20240613104415.9643-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62f; envelope-from=philmd@linaro.org; helo=mail-ej1-x62f.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é --- 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"