From patchwork Wed Apr 20 22:25:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12820871 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC57EC43217 for ; Wed, 20 Apr 2022 22:25:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382805AbiDTW2i (ORCPT ); Wed, 20 Apr 2022 18:28:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380305AbiDTW2a (ORCPT ); Wed, 20 Apr 2022 18:28:30 -0400 Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7C2C41983; Wed, 20 Apr 2022 15:25:34 -0700 (PDT) Received: by mail-qt1-x834.google.com with SMTP id o18so2063223qtk.7; Wed, 20 Apr 2022 15:25:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=yGEzNjv26fUZkerJN19S5j+uBluuftoVLyPl8tEFVgI=; b=YlCDfZY2WsSellZ8sQtSwQunudrhtcHkFKK+m/ZwcQkS6RJcjiVBiw3oSQ+gm9fKLN CvRZVyb5dUJpfrYqqVWSF8pwKamYZ5KdcjBcp1HAJvLS3IqBSPKWjUMNU34au8gAZKdE nhRq381Nzg/1DJBs/R93/lWTCxz9FxgaP0ExNuU7Ek4xoVsSzR5skz+YAf57U1OgMSgY oTV4GwCZYBVn1KCCQiUT9WME1TepygE1l8b/orAvgVnLyhGPz09blXq2D2yOIe8aNRMj dsu1+PoxPDHFPNT2r47/dXwyR3S3VmmWz1QbOy3dMiIbPMbB4knAs9pxB7ejRjlhjZXZ iXeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yGEzNjv26fUZkerJN19S5j+uBluuftoVLyPl8tEFVgI=; b=GHnXkfemlbgYorjRjqqWpXykQGJnW7wxc6A67hInNDVr3+uxiuxCR+7x2wsnIOyf78 MRprrM9hwYwTu86p88+Y5+G2UcGOYQHtbkV1Ier99gKiXvW9AqXxkPyjzRIv4Y+4+Tcj Ol3ahBOPg1lVF/iAv1OpxN7xl0GN/KLp6hJALmpnxPuYTVGN5poBtwP2hX0GxRUevmUA YVT8YVD0fvPoqfci4ihK2jEGflX3iyr+da7wxGSnbaWa9ouayo2kJGjkeeNSVPWwQ8Rm nMAawWH2ChrHmN/L/Fs3QCul2KKrdLWqw0eww9ZCnfhRimj0uY2bNskJyv+/F2UWKYvo Et8w== X-Gm-Message-State: AOAM531EYGPfTDcHMTkhuXFieI8mTnxj5e7Fk6JaKfBlXWhRk2Ribhol mfP+97RZxHZ1xxKvibDI31Sl2rFaQRc= X-Google-Smtp-Source: ABdhPJwfFcdGuS18mNampYGWiv7LRnVZ9031WCdOaVOFiEYbn/Qn8DVd01wYt/CZUyf4eCwjpnjfZw== X-Received: by 2002:ac8:58d2:0:b0:2e1:c5d9:9060 with SMTP id u18-20020ac858d2000000b002e1c5d99060mr15012558qta.168.1650493533822; Wed, 20 Apr 2022 15:25:33 -0700 (PDT) Received: from localhost ([2601:c4:c432:60a:188a:94a5:4e52:4f76]) by smtp.gmail.com with ESMTPSA id p13-20020a05622a048d00b002e1ce0c627csm2652151qtx.58.2022.04.20.15.25.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 15:25:33 -0700 (PDT) From: Yury Norov To: linux-kernel@vger.kernel.org, Alexander Gordeev , Andy Shevchenko , Christian Borntraeger , Claudio Imbrenda , David Hildenbrand , Heiko Carstens , Janosch Frank , Rasmus Villemoes , Sven Schnelle , Vasily Gorbik , Yury Norov , linux-s390@vger.kernel.org, kvm@vger.kernel.org Subject: [PATCH 3/4] KVM: s390: replace bitmap_copy with bitmap_{from,to}_arr64 where appropriate Date: Wed, 20 Apr 2022 15:25:29 -0700 Message-Id: <20220420222530.910125-4-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220420222530.910125-1-yury.norov@gmail.com> References: <20220420222530.910125-1-yury.norov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Copying bitmaps from/to 64-bit arrays with bitmap_copy is not safe in general case. Use designated functions instead. Signed-off-by: Yury Norov Reviewed-by: David Hildenbrand --- arch/s390/kvm/kvm-s390.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 156d1c25a3c1..a353bb43ee48 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -1332,8 +1332,7 @@ static int kvm_s390_set_processor_feat(struct kvm *kvm, mutex_unlock(&kvm->lock); return -EBUSY; } - bitmap_copy(kvm->arch.cpu_feat, (unsigned long *) data.feat, - KVM_S390_VM_CPU_FEAT_NR_BITS); + bitmap_from_arr64(kvm->arch.cpu_feat, data.feat, KVM_S390_VM_CPU_FEAT_NR_BITS); mutex_unlock(&kvm->lock); VM_EVENT(kvm, 3, "SET: guest feat: 0x%16.16llx.0x%16.16llx.0x%16.16llx", data.feat[0], @@ -1504,8 +1503,7 @@ static int kvm_s390_get_processor_feat(struct kvm *kvm, { struct kvm_s390_vm_cpu_feat data; - bitmap_copy((unsigned long *) data.feat, kvm->arch.cpu_feat, - KVM_S390_VM_CPU_FEAT_NR_BITS); + bitmap_to_arr64(data.feat, kvm->arch.cpu_feat, KVM_S390_VM_CPU_FEAT_NR_BITS); if (copy_to_user((void __user *)attr->addr, &data, sizeof(data))) return -EFAULT; VM_EVENT(kvm, 3, "GET: guest feat: 0x%16.16llx.0x%16.16llx.0x%16.16llx", @@ -1520,9 +1518,7 @@ static int kvm_s390_get_machine_feat(struct kvm *kvm, { struct kvm_s390_vm_cpu_feat data; - bitmap_copy((unsigned long *) data.feat, - kvm_s390_available_cpu_feat, - KVM_S390_VM_CPU_FEAT_NR_BITS); + bitmap_to_arr64(data.feat, kvm_s390_available_cpu_feat, KVM_S390_VM_CPU_FEAT_NR_BITS); if (copy_to_user((void __user *)attr->addr, &data, sizeof(data))) return -EFAULT; VM_EVENT(kvm, 3, "GET: host feat: 0x%16.16llx.0x%16.16llx.0x%16.16llx",