Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751781AbcDRWBU (ORCPT ); Mon, 18 Apr 2016 18:01:20 -0400 Received: from mail-by2on0055.outbound.protection.outlook.com ([207.46.100.55]:8000 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751394AbcDRWBS (ORCPT ); Mon, 18 Apr 2016 18:01:18 -0400 Authentication-Results: amd.com; dkim=none (message not signed) header.d=none;amd.com; dmarc=none action=none header.from=amd.com; Subject: Re: [PART1 RFC v4 02/11] KVM: x86: Introducing kvm_x86_ops VM init/uninit hooks To: Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= References: <1460017232-17429-1-git-send-email-Suravee.Suthikulpanit@amd.com> <1460017232-17429-3-git-send-email-Suravee.Suthikulpanit@amd.com> <20160411204937.GA6762@potion.brq.redhat.com> <570D6ED5.4030403@redhat.com> CC: , , , , , , , From: Suravee Suthikulpanit Message-ID: <57155925.2080009@amd.com> Date: Mon, 18 Apr 2016 17:01:09 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <570D6ED5.4030403@redhat.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [165.204.53.123] X-ClientProxiedBy: CY1PR18CA0022.namprd18.prod.outlook.com (10.163.31.32) To BY1PR12MB0437.namprd12.prod.outlook.com (10.162.147.139) X-MS-Office365-Filtering-Correlation-Id: 297a6842-a20d-4581-d2e8-08d367d4f6a5 X-Microsoft-Exchange-Diagnostics: 1;BY1PR12MB0437;2:1EAbquHVLRUQk/DW3r6CXmbtfI6TWO5uitQaQEyw7IrVs3FL5LOAvXknpx8n0Ts1kuoegbMkoWPosaJKjxP4YozataULNsfVuACVrQKYcZVm1gA5sVcPI/fCKspBnPtkgfPavwY4tpsoqRGnVPPJPJTeaNpU8WjBS19htrDinXv9AUExmuJV6N1XXEO7EAss;3:DS+ezAKjgYyN9wh54YbF1CKTVqZ2yptJkpQpkq7RRB5mw9tBm7hAPF8rn4Bp/VDtmIpbmrA4UIkYI3XzsaNt7yLUfIuTT1dqwBkG3GB3pWXjz1YpMCu0MFFwTjBYBeB1 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR12MB0437; X-Microsoft-Exchange-Diagnostics: 1;BY1PR12MB0437;25:9xdJ1dSU5ltyT9KQtsBo5h4H2722TzfpnpafB5bOVVTBgJ8RIV1VRbEud524kuslm0J2xEBlAoAHKMZhVuNXRBhHtmc+znZdJ0i1sEke4RrKvTqj/mZyqLGcsjd4JQUbL2wo8eXjDpl60jqFPlBlwjfiIJgiMVvUjmNcNeqOUMWWWrpYEoRXDXjhm0ng60UJoU+3QBgcP16Rfj4k4SVk7j2g/OHxkXP8Qgw31nw5gysAT3dn5yAWk6MRJSGkncpQkGYOE2gzFfNJYmGdqDadYNb4PEhi7yRGTsn0k0dSa8L+NbBPYcMPil2zLK61X3SUdWzhdcSx6Dt2ET3y+9kO9TTNEKoLRptfYR9DQDxlG1fn81EwiwoPZ2rozke3D8z4p8JWQGNPJNx4wbUM/f7trw8Zh6PeFh1k/CdqAFpBzWdroSDgiZIABolnlyyMEUaYoBTiSDUZGnWPuXJQjYwoySUsE9QwUVj4VBEaQXmco5kc5TSa0C0yOo3DwzSee6EDXc/FSQYpI6pjNIwon59duTXEla8OWTfxW9wlA7DY8O/YZZlbvlxcNahg973oGSItmgjQvqI8uADumJtZuhuT5/aEPMq+/snv6xZn/A3NxqLQCkBnA1+hbx0SxnsgMXutKklHooU6SIBF9mKRbnxGGQ== X-Microsoft-Exchange-Diagnostics: 1;BY1PR12MB0437;20:JtyEnM24liALxPKOoIG2+xCNeojM2U+oaitZZ3n85KgryC0lI2FEmT8x5PDmgPkmyTdNDwleZgxf86RwMywOY0iqgk9EBweJT8wlroZLMpJR85YhzRBjXznOxTpwjx+Fieq2rFRm0vsfEEjc9gDVogmoJQ7GucyskCVB2kpYlgn7zoRXYCSdYKtrHTw0df0l91R9mRwNqS9EkDbcUAoevr6lm1bz0C/AwrWZLQ9dAliTY3HOK8ORpQ5iEw0047aSoIiV8xJCnAtBlDsSY6DlNmHNF6g9A9awMT0nIG02Kd1RxlCPmGOFkEVlJPH/HyP1MClgG9YVOWHcX5rxBP92ZDBh3SV0ulBW5sZUv7d4BnzY3rPkkimlvlTBQOuzH0Q50S0ONEZ3rg/q8WCsqDa8OEo9Vu241mbfDlItNWnDyUMn2OPG0OJtz03uFNtfvruNa5LN3/IWP6tgE7GKpD083gF1LjFGU1df8Y2Yx4+bKkdIJ+LSbNfL70hijdG1a+m7;4:wVh04gMOmH/JIP4Wx5LHTC+xNuSz5XxDBym10wB7qT+jrpVoWwh9ZGwvpqNPPywk4plkCHo9gF7gcK3Kem0J5KVE8AhcRrAbBUkzid/mLfv9Z00rClEJ/uq4oJcBFUpIHMfYDpn2ptX+oAYTskB//NMDJ6G88bAK4fVEUIwlpiVjzXKDDapvNVSGrR1QW36gDuoBeBQmnv6Z9xu1sTZCwhIL8AtjSzL43c9dluquvV+PXs80DnnvOanP3EZXVIaJAw3huwtOAKyi68TinptflAm+kZ03Ztvg1e8WcWqE/FACyyICyhcM04fmtffRLYQ41ZQv3UQqo+4lSZf0DLI7O/5M8LIrAIHmIaAscUAAnWH81kAN6NHRQvFEFEeZaWKOQ0s2ZuGX1xg/GTl/hRe1wdXyUA2ZHBwCg6YgfkMLSZE= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(9101521026)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026);SRVR:BY1PR12MB0437;BCL:0;PCL:0;RULEID:;SRVR:BY1PR12MB0437; X-Forefront-PRVS: 0916FC3A18 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6049001)(6009001)(377454003)(24454002)(36756003)(23676002)(81166005)(586003)(83506001)(93886004)(76176999)(50466002)(54356999)(87266999)(65816999)(1096002)(50986999)(86362001)(64126003)(99136001)(6116002)(3846002)(42186005)(66066001)(4326007)(122286003)(5001770100001)(5008740100001)(2950100001)(2870700001)(77096005)(5004730100002)(117636001)(189998001)(65806001)(65956001)(59896002)(4001350100001)(92566002)(47776003)(2906002)(62816006);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR12MB0437;H:[10.224.4.142];FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCWTFQUjEyTUIwNDM3OzIzOlpydW40Vlp6NHdOalEvWEJKZC9jbWRqekpL?= =?utf-8?B?UkptbTVLQWJSditqYUI5VGR2U21sa0k1MFFFMitiYWhvelB4Nk44bmNQWFE0?= =?utf-8?B?SDRHMDhEYVVTRGZyQ2QxenF5V1libkVTSHhzMXZDTkdmMk8wQzBBVE5LL1k4?= =?utf-8?B?SzZHZ3QxSmVTTFlkNFYvZUU3ZzBmemw2RnNwTXZ4WURZam5ORmRSQVRXY0M4?= =?utf-8?B?S3l5UmZ1UmRmalVjR1J6ZjdTbkZsNFNiUU52NTI0a0RyRUxienVhTUhRYzRY?= =?utf-8?B?M254Zm5iNi9VTDBXQlkxSnJKZlpaaVF1YkdJZFVwYlRXSk13Wm1vVjV3T2ho?= =?utf-8?B?T3lISU5RaXlOVTJsb3NGUVNQQy9sbW9UVGxFNVllRmRMWDR5bXVXWnBIeHZj?= =?utf-8?B?cWZyV3poa1ZJZnl2ODNUQmJvZUw2bSszWDB3bjcydEFHQTd2aFgrSG5Ndi9V?= =?utf-8?B?bHZzcy9xYW9ock1FUkJtcE1NZm9XWU9NdG5Qb3hLdm1KR3dkcG1iUEdpamVC?= =?utf-8?B?K1BuaGdpZjM2U1Y3VENkeXQzMk1kcFY3azVHWnJhaE5OUjJZTUtwdE1DNjBX?= =?utf-8?B?RzJib1VJMm8r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hDUT09?= X-Microsoft-Exchange-Diagnostics: 1;BY1PR12MB0437;5:KGcuGoMVtVyaAPkkukj1rL6JSZwWwHPsSCbmIREabe9TQ90k5RN1RPEmIGsKvlS835qZ2wnTwc83UaCFLPyt2+R6qdQ57TXgJF0vZjHIlrKBs156o9J8xiLClfvNTJsU9O2ZZhXIYyTUZxSojMqg9c7xNaXkUjqRio834f15gNljVPpXfUKpqTpwwFF1pVz/;24:QAbT8yrL/QRwxbRnixNngbNZB/hb7fVDmhNWI1/fH73rQ6TRRklLOt+iU7P5JhMEx2CL5UIMb9zR3R2DWIdciLfMQ9JAl2xVtw6rQ6y6UTY=;7:mvy3tL0d7AqnVrJ7lA4EjvRQUHBfI0ZLgbxo/uh/TykbNTnjQ1fIDyKeg1ojDgbK/K14zK73hqbs0tbp0U7eTXKMUuuvrBAtI3yyQ0EsuJr8ftkJVwYyQHsyEdwQciehYC9LsiHb52GqVLOYSefLPgQLcl+Og69OJSb8H8oA40ovKifvEgC9I/bxh3+yip0jdTOxKSoziRiliUsWm7Fofg==;20:JPHRweb0iD/fX1bchGYw7SXX8WPwSRoDoQAi/gG0qRYG/lR0OPz2jgWQDdjYNK2e4mWd1KUjXIqjKw7h/AsOQQtN+1nEMn1c4rClREnDCXXYDtCpEXtmcdFNhyH+/6M3CZeKiaD33dsU6cupyogSA8d4c+PpBFkiThlcrqumaiLEKoPozDE/43FZeeGKzLOPncNe6OA0afF2QCioilLqM3kiAoOaK0+S/bjyLV5Y32pdrtaF7kwgiv6WCIF3i7lz X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2016 22:01:14.5349 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR12MB0437 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 700 Lines: 27 Paolo, On 04/12/2016 04:55 PM, Paolo Bonzini wrote: > > > On 11/04/2016 22:49, Radim Krčmář wrote: >>>> @@ -7781,6 +7784,9 @@ static void kvm_free_vcpus(struct kvm *kvm) >>>> kvm_for_each_vcpu(i, vcpu, kvm) >>>> kvm_arch_vcpu_free(vcpu); >>>> >>>> + if (kvm_x86_ops->vm_uninit) >>>> + kvm_x86_ops->vm_uninit(kvm); >> vm_uninit() doesn't seem to have much to do with kvm_free_vcpus(), >> please call it from kvm_arch_destroy_vm(). >> >> (kvm_x86_ops.vm_destroy would be a better name then.) > > Especially, you're calling it with struct kvm full of dangling pointer, > so please call it early, right after the "if (current->mm == kvm->mm)" > block. > > Paolo Good point. Thanks, Suravee